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);
复制代码
相关文章
相关标签/搜索