Android 安卓操作栏赢得';不服从背景色

Android 安卓操作栏赢得';不服从背景色,android,android-layout,android-styles,android-actionbar-compat,Android,Android Layout,Android Styles,Android Actionbar Compat,我刚刚将我的项目更新为目标API 22,而我的操作栏样式似乎已经中断。尽管将背景设置为白色,颜色设置为蓝色,但我最终还是得到了一个带有白色文本的黑色操作栏 这是我的应用程序主题 <style name="AppTheme" parent="AppBaseTheme"> <!-- All customizations that are NOT specific to a particular API-level can go here. --> <it

我刚刚将我的项目更新为目标API 22,而我的操作栏样式似乎已经中断。尽管将背景设置为白色,颜色设置为蓝色,但我最终还是得到了一个带有白色文本的黑色操作栏

这是我的应用程序主题

<style name="AppTheme" parent="AppBaseTheme">
    <!-- All customizations that are NOT specific to a particular API-level can go here. -->
    <item name="android:actionBarStyle">@style/MyActionBar</item>
    <item name="android:homeAsUpIndicator">@drawable/up_button</item>
    <item name="android:actionMenuTextAppearance">@style/H4.Other</item>
    <item name="android:actionMenuTextColor">@color/h4_other</item>
    <item name="android:windowContentOverlay">@drawable/header_shadow</item>
    <item name="android:buttonStyle">@style/ButtonStyle.NoCaps</item>
</style>

@样式/MyActionBar
@可拉拔/向上按钮
@样式/H4.其他
@颜色/h4_其他
@可绘制/页眉阴影
@样式/按钮样式.NoCaps
这是我的动作条风格

<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
    <item name="android:title">""</item>
    <item name="android:background">@color/white</item>
    <item name="android:height">@dimen/action_bar_height</item>
    <item name="android:titleTextStyle">@style/H5.Blue</item>
</style>

""
@颜色/白色
@尺寸/作用杆高度
@款式/H5.5蓝色

仅支持Android 3.0及更高版本时,您可以如下定义操作栏的背景:

res/values/themes.xml

<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
       parent="@android:style/Theme.Holo.Light.DarkActionBar">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
</style>

<!-- ActionBar styles -->
<style name="MyActionBar"
       parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
    <item name="android:background">@color/white</item>
</style>
</resources>

@样式/MyActionBar
@颜色/白色
然后将主题应用于整个应用程序或单个活动:

<application android:theme="@style/CustomActionBarTheme" ... />

好的,我想出来了。更新正在使用的app compat库的版本后,某些属性的名称空间需要更改。在我的例子中,它正在从android:background变为只是background,还有其他一些东西。

你的仿真器android版本是什么?如果低于21,请尝试使用
@color/white
@tufan,是否确定?如果我想使用appcompat版本的material themes,我想你不需要v14中的任何属性?检查我的答案……这将帮助你阿米尔是正确的,使用没有android:namespace的属性修复了这个问题。