2014-07-20 21 views
0

我下面這個:http://android-developers.blogspot.de/2013/08/actionbarcompat-and-io-2013-app-source.html顏色代碼不與後臺工作在:>#ff5a00 <

要更改與程序兼容性操作欄的顏色。這裏是我的代碼:

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

但在第二部分中對於11以上的API,代碼與Android前面的工作正常。

感謝所有幫助:)

回答

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

我需要寫在這兩個他們對嗎? – Chimpanse

+0

@OscarJunker,當然 –

+0

工作,真棒 – Chimpanse