Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActionBarSherlock Custom Theme Being Ignored

I'm using ActionBarSherlock and have applied a custom them to alter the appearance of the action bar:

<style name="Theme.MyTheme" parent="@style/Theme.Sherlock">
    <item name="android:actionBarStyle">@style/MyTheme.ActionBarStyle</item>
</style>

<style name="MyTheme.ActionBarStyle" parent="@style/Widget.Sherlock.ActionBar">
    <item name="android:background">@drawable/background_action_bar</item>
    <item name="android:icon">@drawable/image_action_bar_logo</item>
</style>

This works perfectly on a device running jelly bean but when I deploy it on an emulator running 2.2 or 2.3 the custom action bar style is ignored and the default style is used.

Any ideas?

Thanks David

like image 783
user648462 Avatar asked Jan 27 '26 09:01

user648462


1 Answers

You have to adjust the theme and a little:

<style name="Theme.MyTheme" parent="@style/Theme.Sherlock">
    <!-- define the style for ActionBarSherlock -->
    <item name="actionBarStyle">@style/MyTheme.ActionBarStyle</item>

    <!-- define the style for native ActionBar for Android 4 and higher -->
    <item name="android:actionBarStyle">@style/MyTheme.ActionBarStyle</item>
</style>

Edit:

And also adjust the style appropriately:

<style name="MyTheme.ActionBarStyle" parent="@style/Widget.Sherlock.ActionBar">
    <!-- for ActionBarSherlock -->
    <item name="background">@drawable/background_action_bar</item>
    <item name="icon">@drawable/image_action_bar_logo</item>

    <!-- for native ActionBar for Android 4 and higher -->
    <item name="android:background">@drawable/background_action_bar</item>
    <item name="android:icon">@drawable/image_action_bar_logo</item>
</style>
like image 113
Tomik Avatar answered Jan 29 '26 23:01

Tomik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!