Antonio
Antonio

Reputation: 1145

Customize android action bar

I'm trying to create a new theme and customize the action bar:

<resources>

    <style name="Theme.Shappy.Red" parent="Theme.Sherlock.Light">
        <item name="android:actionBarStyle">@style/ActionBar.Shappy.Red</item>
        ...
        ... [some_other_customizations]
    </style>

    <!-- Action bar -->
    <style name="ActionBar.Shappy.Red" parent="@style/Widget.Sherlock.Light.ActionBar.Solid">        
        <item name="android:background">#ffb70000</item>
        <item name="android:titleTextStyle">@style/ActionBar.Title.Shappy.Red</item>
    </style>

    <!-- Action bar text -->
    <style name="ActionBar.Title.Shappy.Red" parent="@style/TextAppearance.Sherlock.Widget.ActionBar.Title">
            <item name="android:textColor">#ddffffff</item>
    </style>
</resources>

As you can see, I'm using Sherlock. This code works fine for API level 14, but it doesn't work for API level 10. I still see the Holo light like action bar. I think the code is correct because [some_other_customizations] are applied correctly. Do you have any suggestion? Thanks.

Upvotes: 0

Views: 1660

Answers (1)

Ahmad
Ahmad

Reputation: 72533

 <item name="android:actionBarStyle">@style/ActionBar.Shappy.Red</item>

and everything else with "android:" infront of it applies to the default actionbar. You have to put this in your styles as well:

<item name="actionBarStyle">@style/ActionBar.Shappy.Red</item>

This overrides the styles of the ABS. So your Styles should look like this in order to work in API Levels 13<:

<style name="Theme.Shappy.Red" parent="Theme.Sherlock.Light">
    <item name="android:actionBarStyle">@style/ActionBar.Shappy.Red</item>
    <item name="actionBarStyle">@style/ActionBar.Shappy.Red</item>
</style>

<!-- Action bar -->
<style name="ActionBar.Shappy.Red" parent="@style/Widget.Sherlock.Light.ActionBar.Solid">
    <item name="android:background">#ffb70000</item>
    <item name="background">#ffb70000</item>
    <item name="android:titleTextStyle">@style/ActionBar.Title.Shappy.Red</item>
    <item name="titleTextStyle">@style/ActionBar.Title.Shappy.Red</item>
</style>

<!-- Action bar text -->
<style name="ActionBar.Title.Shappy.Red" parent="@style/TextAppearance.Sherlock.Widget.ActionBar.Title">
    <item name="android:textColor">#ddffffff</item>
    <item name="textColor">#ddffffff</item>
</style>

Upvotes: 4

Related Questions