【发布时间】:2021-02-05 10:43:17
【问题描述】:
我拥有 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)
}
但我的问题是这不能覆盖主题集值,因此我需要全部使用样式或全部在代码中完成。
我的问题是,这是打算这样还是我在某个地方遗漏了什么?
【问题讨论】:
-
疯狂的机器人。也不起作用,我只是使用已弃用的 API,一切正常(别无选择)¯_(ツ)_/¯
标签: android android-theme android-styles android-11 windowinsets