Wednesday, 28 October 2020

Android API level 30 setSystemBarsAppearance doesn't overwrite theme data

Pre-Android 11 (API Level 30) I had <item name="android:windowLightStatusBar">true</item> set in my theme and was additionally changing this (when needed) in the the code with

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() }
}

However, Android-30 adds a new way to control with

fun setLightStatusBar(){ 
    window?.insetsController?.setSystemBarsAppearance(APPEARANCE_LIGHT_STATUS_BARS, APPEARANCE_LIGHT_STATUS_BARS)
} 

fun setDarkStatusBar(){
    window?.insetsController?.setSystemBarsAppearance(0, APPEARANCE_LIGHT_STATUS_BARS)
}

but my issue is that this cannot overwrite the theme-set values and thus I need to either do it all with styles or all in code.

My question is if this is intended to be like this or am I missing something somewhere?



from Android API level 30 setSystemBarsAppearance doesn't overwrite theme data

No comments:

Post a Comment