Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change ActionBar Tabs background color

Is there a way to change the background color of the tab bar in the ActionBar without changing it in the one line version?

To clarify what I want: In portrait mode the ActionBar is split in two lines, the ActionBar itself and the tabs below. In landscape mode the tabs are in the actual ActionBar.

I want to change the background color of the portrait mode. If I change the background in the TabView it'll be changed for both modes. Do I have to create separate styles for those? Which brings up a second question: is there a way to know when it'll be two lines and when not?

Or am I just missing something?

I'm using ActionBarSherlock btw

like image 812
Maria Neumayer Avatar asked Jul 03 '12 20:07

Maria Neumayer


People also ask

How to change color of action bar in Android?

ActionBar actionbar = getActionBar(); actionbar. setBackgroundDrawable(new ColorDrawable("color"));


1 Answers

I think you are looking for the android:backgroundStacked attribute of the ActionBar style:

<style name="MyTheme" parent="android:Theme.Holo.Light">
    <item name="android:actionBarStyle">@style/MyActionBarStyle</item>
</style>

<style name="MyActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar.Solid">
    <item name="android:backgroundStacked">@drawable/my_stacked_background</item>
</style>

or (If using ActionBarSherlock):

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

<style name="MyActionBarStyle" parent="@style/Widget.Sherlock.Light.ActionBar.Solid">
    <item name="android:backgroundStacked">@drawable/my_stacked_background</item>
    <item name="backgroundStacked">@drawable/my_stacked_background</item>
</style>
like image 123
JesperB Avatar answered Nov 03 '22 11:11

JesperB