StatusBarCompat是一个用于设置系统状态栏颜色的兼容库,兼容Android 4.4.2(API 19)以上,使用简单,仅需要一行代码的调用。
- Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
- Add the dependency
dependencies {
compile 'com.github.yuminfeng:statusbarcompat:v0.4'
}
- 开始使用
//设置状态栏颜色
StatusBarCompat.newBuilder()
.statusColor(ContextCompat.getColor(this, R.color.colorPrimaryDark))
.build(this)
.apply();
//设置状态栏透明
StatusBarCompat.newBuilder()
.statusBarTransparent(true)
.build(this)
.apply();
//设置全屏模式
StatusBarCompat.newBuilder()
.fullScreen(true)
.build(this)
.apply();