Search code examples
androidstatusbar

The status bar does not change color


I have followed all tutorials and cannot get my statusbar to change color despite having set all attributes:

<resources xmlns:tools="http://schemas.android.com/tools">
    <!-- Base application theme. -->
    <style name="Theme.FestiLab" parent="Theme.Material3.DayNight">
        <!-- Primary brand color. -->
        <item name="colorPrimary">#293859</item>
        <item name="colorPrimaryVariant">#293859</item>
        <item name="colorOnPrimary">#FFFFFF</item>
        <item name="android:statusBarColor">#293859</item>
        <item name="colorSecondaryVariant">#293859</item>
        <item name="colorSecondary">#293859</item>
        <item name="android:windowTranslucentStatus">false</item>
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
        <item name="toolbarStyle">@style/Theme.Custom.Toolbar</item>
    </style>

    <style name="Theme.Custom.Toolbar" parent="Widget.Material3.Toolbar">
        <item name="android:background">#293859</item>
    </style>
</resources>

I doubled checked, an,d no code override opr whatsoever

My manifest is also correct as if I change other settings from theme.xml, they are reflected.

I feel really stupid there.. Thanks fior any help µ EDSIT: I also tried with Theme.MaterialComponents.DayNight.DarkActionBar


Solution

  • This is most likely caused by the Edge-to-edge enforcement introduced in Android 15 (API level 35) which enforces a transparent background for the system status and navigation bar.

    In the transition period until you can fully adapt your app to properly work edge-to-edge you can opt-out of the enforcement using windowOptOutEdgeToEdgeEnforcement. This will only work when targeting API level 35, though. It is deprecated in API level 36 and won't have an effect anymore.