Vik*_*nov 16 android android-theme android-styles windowinsets android-11
Android 11 之前(API 级别 30)我已经
<item name="android:windowLightStatusBar">true</item>
在我的主题中设置,并且还在代码中(在需要时)使用
fun setLightStatusBar(){
window?.decorView?.let { it.systemUiVisibility = it.systemUiVisibility or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR }
}
fun setDarkStatusBar(){
window?.decorView?.let { it.systemUiVisibility = it.systemUiVisibility and View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR.inv() }
}
Run Code Online (Sandbox Code Playgroud)
然而,Android-30 增加了一种新的控制方式
fun setLightStatusBar(){
window?.insetsController?.setSystemBarsAppearance(APPEARANCE_LIGHT_STATUS_BARS, APPEARANCE_LIGHT_STATUS_BARS)
}
fun setDarkStatusBar(){
window?.insetsController?.setSystemBarsAppearance(0, APPEARANCE_LIGHT_STATUS_BARS)
}
Run Code Online (Sandbox Code Playgroud)
但我的问题是这不能覆盖主题集值,因此我需要全部使用样式或全部使用代码。
我的问题是,这是打算像这样还是我在某处遗漏了什么?