Style an Action Bar in Android Honeycomb

坚强是说给别人听的谎言 提交于 2019-12-20 10:35:53

问题


I'd like to set the background of an action bar (Honeycomb) using themes and styles. You can do it in code with ActionBar.setBackgroundDrawable(Drawable), but I can't find the corresponding style attributes.

I have tried using this theme and style for my Activity:

<style name="Theme.MyApp" parent="android:style/Theme.Holo">
    <item name="android:actionBarStyle">@style/ActionBar</item>
</style>

<style name="ActionBar">
    <item name="android:background">@drawable/action_bar_background</item>
</style>

but this puts the background over the app icon and title on the left. The menu icons on the right are fine and the background is under it.

So is there anyway to do this?


回答1:


Ok, I figured it out. I needed to inherit from the base action bar style. The correct styles are:

<style name="Theme.MyApp" parent="android:style/Theme.Holo">
    <item name="android:actionBarStyle">@style/ActionBar</item>
</style>

<style name="ActionBar" parent="android:style/Widget.Holo.ActionBar">
    <item name="android:background">@drawable/action_bar_background</item>
</style>


来源:https://stackoverflow.com/questions/5123086/style-an-action-bar-in-android-honeycomb

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