简体   繁体   中英

Android statusbar and actionbar resolve to grey

I recently split my values into two:

  • values/style.xml
  • values-v21/style.xml

my v21/style.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Theme.Foodie" parent="Theme.AppCompat.Light.NoActionBar">

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

        <item name="android:windowContentTransitions">true</item>
        <item name="android:windowAllowEnterTransitionOverlap">true</item>
        <item name="android:windowAllowReturnTransitionOverlap">true</item>

    </style>
</resources>

my style.xml

<resources>
    <style name="Theme.Foodie" parent="Theme.AppCompat.Light.NoActionBar">
        <!--<item name="windowActionModeOverlay">true</item>-->
        <item name="colorPrimary">@color/theme_primary</item>
        <item name="colorPrimaryDark">@color/theme_primary_dark</item>
        <item name="colorAccent">@color/theme_accent</item>

    </style>
</resources>

And my toolbar:

<!-- We use a Toolbar so that our drawer can be displayed
     in front of the action bar -->
<android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/toolbar_actionbar"
    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
    android:layout_height="?actionBarSize"
    android:layout_width="match_parent"
    android:minHeight="?attr/actionBarSize"
    android:background="?attr/colorPrimary"/>

Somehow, we toolbar background's resolve to grey! Same for the statusbar when I compile:

灰色操作栏

And I'm not sure if that's linked, but I recently cleaned my project before building it.

Do you know what's happening?

Use Toolbar code like this:

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay">

            //..........

        </android.support.v7.widget.Toolbar>

and in style.xml will like this:

<style name="AppTheme" parent="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="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

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

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

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