Reputation: 42592
I am using Android native action bar. I would like to add my own drawable resource as the background of the action bar. So, I made a theme like following:
res/values/themes.xml :
<style name="Theme.MyStyle" parent="android:style/Theme.Holo.Light">
<item name="android:background">@drawable/my_bg</item>
</style>
Then, in AndroidManifest.xml file I add this style to my application:
<application
android:debuggable="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.MyStyle"
>
<activity ...>
<activity .../>
...
</application>
BUT, the background drawable is applied NOT ONLY to action bar BUT ALSO to all fragments' content. why?
My 2nd question is, how to customize the overflow icon and the left-most "up" button on action bar??
Upvotes: 2
Views: 3854
Reputation: 1182
try
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="Theme.MyStyle" parent="@android:style/Theme.Holo">
<item name="android:actionBarStyle">@style/MyActionBar</item>
<!-- other activity and action bar styles here -->
</style>
<!-- style for the action bar backgrounds -->
<style name="MyActionBar" parent="@android:style/Widget.Holo.ActionBar">
<item name="android:background">@drawable/ab_background</item>
<item name="android:backgroundStacked">@drawable/ab_background</item>
<item name="android:backgroundSplit">@drawable/ab_split_background</item>
</style>
</resources>
customize the logo using setDisplayUseLogoEnabled(boolean)
Upvotes: 6