custom style action bar not working in android 4

◇◆丶佛笑我妖孽 提交于 2020-01-11 09:21:47

问题


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>

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.


回答1:


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.

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.



来源:https://stackoverflow.com/questions/18726865/custom-style-action-bar-not-working-in-android-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!