2014-05-15 44 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