2014-05-15 42 views
0

我這種提取物直接複製從Android在線文檔Styling the Action Bar樣式化操作欄兼容性

對於Android的3.0和更高版本僅

在支持Android 3.0的,只有更高,您可以定義操作欄的背景是這樣:

res/values/themes.xml 
<?xml version="1.0" encoding="utf-8"?> 
<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">@drawable/actionbar_background</item> 
    </style> 
</resources> 

我的minSdk是11,但我在父標籤處收到兼容性警告。爲什麼?

回答

0

Theme.Holo.Light.DarkActionBar只有4.0+,這就是爲什麼你會得到警告。爲了解決這個問題,你可以使用Holo Light,或者根據Android版本更改主題(這樣你就可以在ICS +上使用Honeycomb和Light了,並帶有黑暗的動作條)。

+0

你是說在文檔中有錯誤嗎? – user2798694

+0

是的,DarkActionBar是SDK 14+ – Spotlight

+0

你能告訴我一個如何解決它的例子嗎? – user2798694