admin管理员组

文章数量:1287147

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

<resources xmlns: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

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

<resources xmlns:tools="http://schemas.android/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

Share Improve this question asked Feb 24 at 11:21 Waza_BeWaza_Be 39.6k50 gold badges191 silver badges262 bronze badges 5
  • What Android version are you targeting and use for testing? – tyg Commented Feb 24 at 11:31
  • targetSdk = 35, compileSdk = 35, on a Pixel 8 with Android 15 – Waza_Be Commented Feb 24 at 11:32
  • @tyg THANKS your comment helped me to Google it again with Android 5, and I found! <item name="android:windowOptOutEdgeToEdgeEnforcement">true</item> You can add it as an answer, I will gladly accept – Waza_Be Commented Feb 24 at 11:33
  • 1 This question is similar to: How to change the status bar color in Android 15+?. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. – Livio Commented Feb 24 at 12:29
  • @Waza_Be that windowOptOutEdgeToEdgeEnforcement is only temporary and wont work in later versions so you might as well just support the transparent status bar correctly – tyczj Commented Feb 24 at 13:19
Add a comment  | 

1 Answer 1

Reset to default 1

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.

本文标签: androidThe status bar does not change colorStack Overflow