有人能帮我理解为什么这段代码没有把Android操作条变成黄色吗?
我按照更改操作栏颜色的方法编写了如下代码,但操作栏仍然按照全息灯主题显示 styles.xml:有人能帮我理解为什么这段代码没有把Android操作条变成黄色吗?,android,android-styles,android-actionbar-compat,Android,Android Styles,Android Actionbar Compat,我按照更改操作栏颜色的方法编写了如下代码,但操作栏仍然按照全息灯主题显示 styles.xml: <style name="CustomActionBarTheme" parent="@style/Theme.AppCompat.Light"> <!-- Support library compatibility --> <item name="actionBarStyle">@style/MyActionBar</item&g
<style name="CustomActionBarTheme" parent="@style/Theme.AppCompat.Light">
<!-- Support library compatibility -->
<item name="actionBarStyle">@style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar">
<!-- Support library compatibility -->
<item name="background">@color/yellow</item>
</style>
@样式/MyActionBar
@颜色/黄色
Android清单:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat.Light" >
<activity
android:name="com.example.labside.MainActivity"
android:label="@string/app_name"
android:theme="@style/CustomActionBarTheme" >
colors.xml将黄色定义为#FFFF00。请让我知道我做错了什么,因为关于支持API级别8的操作栏样式的整个内容开始变得非常混乱!一如既往,非常感谢您的帮助!!:) 您使用的是什么android版本?请看这篇文章: 在这篇文章之后,您需要声明两次自定义样式。看起来您缺少带有
android:
前缀的声明
所以我想,你必须加上:
<item name="android:background">@color/yellow</item>
@颜色/黄色
非常感谢!!我遵循了您共享的帖子,并使用“tools:targetApi=”11“属性为API11及更高版本添加了android:actionBarStyle、android:background项。这种颜色变化现在可以在我的Android 4.2设备上使用。