Is it possible to make white status bar programmatically in dark mode? (Application is based on single Activity, and I have to make this only for one fragment)
also app should based on Theme.MaterialComponents.Light.NoActionBar
to have no bad effect on other styles.
I've tried to set white color and ui visibility to light mode, but it seems force dark is applied to status bar background automatically.
the code looks like this:
var flags = it.decorView.systemUiVisibility or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
window.decorView.systemUiVisibility = flags
//it is #F0F0F0 in white and night sources
var statusBarColor = context.getColorCompat(R.color.white)
window?.statusBarColor = statusBarColor
but only systemUiVisibility flag applies:
ok, answer was in the question... but I haven't think to try to disable force dark before...
as I've mentioned as Theme.MaterialComponents.Light.NoActionBar
been used I have to disable forceDark.
so the solution in this case looks like:
val decorView = window.decorView
val wic = WindowInsetsControllerCompat(window, decorView)
wic.isAppearanceLightStatusBars = true
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
//disable force dark for Light theme
window.decorView.isForceDarkAllowed = false
}
window.statusBarColor = Color.WHITE