效果

左侧为沉浸式
集成方法
- 添加依赖
implementation 'com.gyf.immersionbar:immersionbar:3.0.0'
implementation 'com.gyf.immersionbar:immersionbar-ktx:3.0.0'
- Manifest中application节点下增加
<!--适配华为(huawei)刘海屏-->
<meta-data
android:name="android.notch_support"
android:value="true" />
<!--适配小米(xiaomi)刘海屏-->
<meta-data
android:name="notch.config"
android:value="portrait|landscape" />
<!--适配全面屏-->
<meta-data
android:name="android.max_aspect"
android:value="2.4" />
- 代码中设置(如activity)
private fun initImmersionBar() {
immersionBar {
val typedValue = TypedValue()
theme.resolveAttribute(R.attr.colorPrimary, typedValue, true)
statusBarColor(typedValue.resourceId).autoStatusBarDarkModeEnable(true, 0.2f)
}
}
完整源代码
https://gitee.com/cxyzy1/ImmersionBarDemo
网友评论