简体   繁体   中英

Status Bar color doesn't change

I started an default Navigation Drawer Project in Android Studio. After that i added a second activity. But in the layout of this second activity the status bar is white although it has the same theme like the automatically created layout where the colorPrimaryDark attribute works fine.

I played around a bit and figured out that a newly created theme CustomTheme which got the same items as AppTheme works great.

So using android:theme="@style/CustomTheme.NoActionBar" works but android:theme="@style/AppTheme.NoActionBar" doesn't. Changing the default application theme has no effect.

This is my styles.xml

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

<style name="AppTheme.NoActionBar">
    <item name="colorPrimaryDark">#3fff04</item>
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>



<style name="CustomTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

<style name="CustomTheme.NoActionBar">
    <item name="colorPrimaryDark">#ff0404</item>
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

So, can you maybe explain me this little thing?

Thanks a lot for your help!

<style name="AppBaseTheme" parent="Theme.AppCompat.Light">

</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
    <!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>

<style name="NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowActionBar">false</item>
    <item name="android:windowNoTitle">true</item>
</style>

<style name="APPActionBar" parent="@style/AppBaseTheme">
    <item name="colorPrimary">@color/action_bar_clr</item>
    <item name="android:textColorPrimary">@color/white</item>
    <item name="actionOverflowMenuStyle">@style/PopupMenu</item>
</style>

<style name="PopupMenu" parent="Widget.AppCompat.PopupMenu.Overflow">
    <item name="android:textColor">@color/white</item>
    <item name="android:popupBackground">@color/menu_bg</item>
</style>

Your AndroidManifest.file add theme

 android:theme="@style/APPActionBar"

use same style as value-11 and value-14 folder

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM