Android 沉浸式状态栏,支持状态栏渐变色,纯色, 全屏,亮光、暗色模式,适配 android 4.4 -10.0 机型,支持刘海屏,滴水屏

StatusBarUtil

项目地址:Ye-Miao/StatusBarUtil 

简介: Android 沉浸式状态栏,支持状态栏渐变色,纯色, 全屏,亮光、暗色模式,适配 android 4.4 -10.0 机型,支持刘海屏,滴水屏

更多:作者   提 Bug   

标签:

 

Android 沉浸式状态栏,支持状态栏渐变色,纯色, 全屏,亮光、暗色模式,适配 android 4.4 -10.0 机型,支持刘海屏,滴水屏

    

English

Apk

Download Apk

机型演示

Android-9.0Android-4.4

Gradle 引用

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

dependencies {
    implementation 'com.github.Ye-Miao:StatusBarUtil:1.7.5'
}

使用方法

1.设置纯色状态栏

XML 布局

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

activity 中使用

StatusBarUtil.setColor(this, mColor);

2.设置渐变色状态栏

XML 布局

<android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@drable/gradient_color"/>

activity 中使用

StatusBarUtil.setGradientColor(this, mToolbar);

3.设置透明状态栏

activity 中使用

StatusBarUtil.setTransparentForWindow(this);

特别注意,如果设置的是白色透明状态栏模式,那么状态栏上方的字体颜色会被覆盖,显示不清楚,只需要再增加一句

StatusBarUtil.setDarkMode(this);

4.设置亮色状态栏,改变状态栏上方的字体颜色(适用于 Android6.0 及以上)

activity 中使用

StatusBarUtil.setLightMode(this);

5.设置暗色状态栏,改变状态栏上方的字体颜色(适用于 Android6.0 及以上)

activity 中使用

StatusBarUtil.setDarkMode(this);

6.增加 View 的 paddingTop,增加的值是状态栏高度(具体用途可以在 demo 中查看)

  • 可以将 Toolbar 高度延伸到状态栏以实现纯色状态栏 XML 布局
    <android.support.v7.widget.Toolbar
          android:id="@+id/toolbar"
          android:layout_width="match_parent"
          android:layout_height="?attr/actionBarSize"
          android:background="@color/blue"/>
    
    activity 中使用
    StatusBarUtil.setPaddingTop(this, mToolbar);
    
  • 可以将 Toolbar 高度延伸到状态栏以实现渐变色状态栏 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"
    
    activity 中使用
    StatusBarUtil.setPaddingTop(this, mToolbar);
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值