Android沉浸式狀態欄,支持狀態欄漸變色,純色, 全屏,亮光、暗色模式,適配android 4.4 -10.0機型

StatusBarUtil

適用於Android 4.4-10.0型號的狀態欄,具備改進的色彩,漸變和沉浸式體驗android

Sample

Download Apkgit

Demo

Demo Linkgithub

機型演示

Android-9.0 Android-4.4

Gradle引用

repositories {
    ...
    maven { url 'https://www.jitpack.io' }
}

dependencies {
    implementation 'com.github.Ye-Miao:StatusBarUtil:1.7.5'
}
複製代碼

使用方法

設置純色狀態欄

in your layout XMLbash

<android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@color/blue"/>
複製代碼

in your activitymaven

StatusBarUtil.setColor(this, mColor);
複製代碼

設置漸變色狀態欄

in your layout XMLthis

<android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@color/blue"/>
複製代碼

in your activityurl

StatusBarUtil.setGradientColor(this, mToolbar);
複製代碼

設置透明狀態欄

in your activityspa

StatusBarUtil.setTransparentForWindow(this);
複製代碼

設置亮色狀態欄(適用於Android6.0及以上)

in your activitycode

StatusBarUtil.setLightMode(this);
複製代碼

設置暗色狀態欄(適用於Android6.0及以上)

in your activitycdn

StatusBarUtil.setDarkMode(this);
複製代碼

增長View的paddingTop,增長的值是狀態欄高度(具體用途能夠在demo中引用)

能夠將Toolbar高度延伸到狀態欄以實現純色狀態欄

in your layout XML

<android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@color/blue"/>
複製代碼

in your activity

StatusBarUtil.setPaddingTop(this, mToolbar);
複製代碼

能夠將Toolbar高度延伸到狀態欄以實現漸變色狀態欄

in your layout XML

<android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@color/gradient_color"
複製代碼

in your activity

StatusBarUtil.setPaddingTop(this, mToolbar);
複製代碼
相關文章
相關標籤/搜索