Question

I'm attempting to change the colors on my ActionBar Tabs to match the colors used in my app. I've been following the blog post here: http://blog.alwold.com/2013/08/28/styling-tabs-in-the-android-action-bar/ which is very helpful. However when setting up the theme in Step 1 I can't find the correct value for the parent attribute. The website lists "Theme.Sherlock", but I'm not using ActionBarSherlock, so that doesn't apply.

My XML is as follows:

<style name="PropertyApp" parent="@style/Widget.Holo.ActionBar.TabView">
    <item name="android:actionBarTabStyle">@style/PropertyApp.ActionBar.Tab</item>
    <item name="actionBarTabStyle">@style/FindMyTrain.ActionBar.Tab</item>
</style>

<style name="PropertyApp.ActionBar.Tab">
    <item name="android:background">@drawable/tab_bar_background</item>
</style>

No matter what I use for the parent style in the top style definition, I get an error that "No resource found that matches the given name: attr 'actionBarTabStyle'". Also, I'm told that the symbol "PropertyApp.ActionBar.Tab" cannot be resolved.

Was it helpful?

Solution

Your issue is that you are specifying the Widget.Holo.ActionBar.TabView parent style for your main PropertyApp style.

You will need to put that in your PropertyApp.ActionBar.Tab style.

Then put the main parent theme for PropertyApp like Theme.Holo.

<style name="PropertyApp" parent="android:style/Theme.Holo">
    <item name="android:actionBarTabStyle">@style/PropertyApp.ActionBar.Tab</item>
</style>

<style name="PropertyApp.ActionBar.Tab" parent="android:style/Widget.Holo.ActionBar.TabView">
    <item name="android:background">@drawable/tab_bar_background</item>
</style>

The naming of the parent styles will also depend on which API levels you are targeting. AppCompat for example if you are using that.

You can refer to the documentation on changing the tab backgrounds.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top