欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android 詳解沉浸式狀態(tài)欄的實現(xiàn)流程

 更新時間:2021年11月08日 17:22:30   作者:LuckyLazyPig  
沉浸式就是要給用戶提供完全沉浸的體驗,使用戶有一種置身于虛擬世界之中的感覺。沉浸式模式就是整個屏幕中顯示都是應用的內(nèi)容,沒有狀態(tài)欄也沒有導航欄,用戶不會被一些系統(tǒng)的界面元素所打擾,讓我們來實現(xiàn)下網(wǎng)上傳的沸沸揚揚的安卓沉浸式狀態(tài)欄

Android—沉浸式狀態(tài)欄

image

我們的征程是星辰大海,而非人間煙塵

去掉標題欄

首先去掉對應主題下面的Android自帶的ActionBar,只需要在對應主題下面加NoActionBar

效果

引入依賴

implementation 'com.jaeger.statusbarutil:library:1.5.1'

沉浸狀態(tài)欄顏色

沉浸式狀態(tài)欄,既可以把顏色實現(xiàn)沉浸,又可以把圖片實現(xiàn)沉浸。

未設置顏色沉浸的狀態(tài):

image

邏輯代碼:

StatusBarUtil.setColor(MainActivity.this,getResources().getColor(R.color.teal_200),0)

image

布局文件

image

沉浸狀態(tài)欄圖片

未沉浸之前的效果

image

沉浸之后的效果

image

布局代碼

  • 將要沉浸的圖片放在ImageView組件里面
  • 其他的組件放在一個布局里面
  • 通過一個setTransparentForImageView方法替換

image

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="0dp"
        android:layout_height="250dp"
        android:src="@drawable/w"
        android:layout_margin="0dp"
        android:padding="0dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/constraintLayout"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/imageView">


        <Button
            android:id="@+id/button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="115dp"
            android:text="Button"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent" />
    </androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

邏輯代碼

image

StatusBarUtil.setTransparentForImageView(this,findViewById(R.id.constraintLayout));

StatusBarUtil官網(wǎng)

到此這篇關(guān)于Android 詳解沉浸式狀態(tài)欄的實現(xiàn)流程的文章就介紹到這了,更多相關(guān)Android 沉浸式狀態(tài)欄內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論