自定义样式操作栏不工作在安卓4.0 [英] custom style action bar not working in android 4
问题描述
有关定制我的行动吧我在XML中使用code如下:
For customizing my action bar I use code below in xml:
<style name="CustomActionbarTheme" parent="@style/Theme.AppCompat.Light">
<item name="actionBarTabStyle">@style/customTab</item>
<item name="actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="@style/Widget.AppCompat.ActionBar">
<item name="background">@drawable/title_bar</item>
</style>
<style name="customTab" parent="@style/Widget.AppCompat.ActionBar.TabView">
<item name="android:background">@drawable/tab_bg_selector</item>
</style>
我在使用API级别10没有问题,但是当我运行我的code较高的API设备,动作条在他们的默认主题。我使用支持库V7在我的项目。 在先进的感谢。
I have no problem using api level 10 but when I run my code in higher api devices, action bars are in their default theme. I use support library v7 in my project. Thanks in advanced.
推荐答案
更新:为的 AppCompat版本21 的,所有的API级别现在使用的非prefixed风格的名称,这样就不再需要添加 Android的:
命名空间的属性。
Update: as of AppCompat version 21, all API levels now use the non-prefixed style names so there is no longer a need to add the android:
namespaced attributes.
现在过时了::如果您使用的是支持库V7 动作条
,你需要无<$申报您的自定义样式两次,一次C $ C>机器人: preFIX(对于LT; V11的支持 - 这是你所拥有的),一次用(对于GT; = V11支持 - 你需要添加此),按照该风格化的操作栏指南。
Now obsolete: If you are using the support library v7 ActionBar
, you need to declare your custom styles twice, once without the android:
prefix (for <v11 support - this is what you have) and once with (for >=v11 support - you need to add this) as per the Styling the Action Bar guide.
这篇关于自定义样式操作栏不工作在安卓4.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!