Android状态栏和操作栏解析为灰色

时间:2015-03-16 09:33:05

标签: android xml android-5.0-lollipop toolbar statusbar

我最近把我的价值分成了两个:

  • values / style.xml
  • 值-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>

我的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>

我的工具栏:

<!-- 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"/>

不知何故,我们工具栏背景的决心变灰了!编译时状态栏的内容相同:

grey action bar

我不确定这是否已关联,但我最近在构建它之前清理了我的项目。

你知道发生了什么吗?

1 个答案:

答案 0 :(得分:0)

使用像这样的工具栏代码:

        <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>

并在style.xml中会这样:

<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" />