开发者

Style an Action Bar in Android Honeycomb

开发者 https://www.devze.com 2023-02-14 01:18 出处:网络
I\'d like to开发者_C百科 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 correspond

I'd like to开发者_C百科 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?


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>
0

精彩评论

暂无评论...
验证码 换一张
取 消