颜色代码不适用于背景:>#ff5a00<

时间:2014-07-20 15:57:35

标签: android android-actionbar

我正在关注此事:http://android-developers.blogspot.de/2013/08/actionbarcompat-and-io-2013-app-source.html

使用appCompat更改操作栏的颜色。这是我的代码:

** res / Styles.xml **

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"/>'

<style name="Theme.Styled" parent="@style/Theme.AppCompat.Light.DarkActionBar">
    <!-- Setting values in the default namespace affects API levels 7-13 -->
    <item name="actionBarStyle">@style/Widget.Styled.ActionBar</item>
</style>

<style name="Widget.Styled.ActionBar" parent="@style/Widget.AppCompat.Light.ActionBar">
    <!-- Setting values in the default namespace affects API levels 7-13 -->
    <item name="background">#ff5a00</item>
</style>

RES /值-V11 / Styles.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Styled" parent="@style/Theme.AppCompat.Light.DarkActionBar">
    <!-- Setting values in the default namespace affects API levels 7-13 -->
    <item name="actionBarStyle">@style/Widget.Styled.ActionBar</item>
</style>

<style name="Widget.Styled.ActionBar" parent="@style/Widget.AppCompat.Light.ActionBar">
    <!-- Setting values in the default namespace affects API levels 7-13 -->
    <item name="android:background">#ff5a00</item>
</style>

在代码的第一部分#ff5a00给我错误:无法解析符号#ff5a00

但是在api 11的第二部分中,代码在Android前面运行良好。

感谢任何帮助:)

1 个答案:

答案 0 :(得分:1)

而不是<resources>,写

<resources xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android">

将您的颜色放在color.xml中

<item name="background">@color/red</item>

和值-v11:

<item name="android:background">@color/red</item>