Pre-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() }
}
然而,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)
}
但我的问题是这不能覆盖主题集值,因此我需要全部使用样式或全部使用代码。
我的问题是,如果这是打算这样,还是我在某处遗漏了什么?