"android:windowLightStatusBar" not working

Viewed 2512

I seriously do not how this is not working. Even though I do have an API way beyond 23 the status bar text color remains white even when windowLighStatusBar is set to true. Here is my application theme:

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
    <item name="colorPrimary">@color/offWhite</item>
    <item name="colorOnPrimary">@color/black</item>
    <item name="colorPrimaryDark">@color/offWhite</item>
    <item name="colorOnSurface">@color/black</item>
    <item name="colorSurface">@color/grey</item>
    <item name="colorSecondary">@color/monaYellow</item>
    <item name="colorSecondaryVariant">@color/bluePowder</item>
    <item name="android:colorBackground">@color/offWhite</item>

    <item name="android:windowLightNavigationBar">true</item>
    <item name="android:windowLightStatusBar">true</item>
</style>

I appreciate the help in advance.

3 Answers

Because you are setting;

<item name="android:windowLightNavigationBar">true</item>

I think you also want to set;

<item name="android:windowDrawsSystemBarBackgrounds">true</item>

Details of windowLightNavigationBar from the docs:

"For this to take effect, the window must be drawing the system bar backgrounds with windowDrawsSystemBarBackgrounds and the status bar must not have been requested to be translucent with windowTranslucentStatus."

https://developer.android.com/reference/android/R.attr#windowLightStatusBar

You can set it programmatically for API>=23 like this:

window!!.decorView.systemUiVisibility=View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR

Call this before setting contentView() in Activity

I think you meant statusBarColor only to change its colors

<item name="android:statusBarColor">@color/yourcolor</item>
Related