Before to make the android status bar have dark icons you would use the following code
// Enables Dark Status Bar Icons//
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
With android 11 both systemUiVisibility
and View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
are deprecated
How can I achieve the same result in android 11
Thanks
It was a lot of figuring out, but you need the WindowInsetsController
. There are different ways to get this controller. Using window.insetsController
or view.windowInsetsController
. At application startup the window version seems to crash, so at startup I now do window.decorView.windowInsetsController
.
As described here you can show or remove the light status bar like this:
setSystemBarsAppearance(APPEARANCE_LIGHT_STATUS_BARS, APPEARANCE_LIGHT_STATUS_BARS) //Show
setSystemBarsAppearance(0, APPEARANCE_LIGHT_STATUS_BARS) //Remove