Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"android:windowLightStatusBar" not working

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.

like image 212
matija Avatar asked Oct 15 '22 04:10

matija


2 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

like image 172
CzarMatt Avatar answered Oct 18 '22 14:10

CzarMatt


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

like image 21
Soumik Bhattacharjee Avatar answered Oct 18 '22 14:10

Soumik Bhattacharjee