Android 3.0 ActionBar, changing colors

19,663

Solution 1

You can control the appearance of the tabs by using the properties android:actionBarTabStyle, android:actionBarTabBarStyle, and android:actionBarTabTextStyle.

This section in the official developer guide shows a sample xml to customize the action bar's style.

Regarding the text of the menu options check the properties actionMenuTextAppearance and actionMenuTextColor.

Solution 2

As additional info, here's how I found out how to change the blue bar below each tab (the answer above is perfectly good, but I lacked little information that I put here, which might be useful to somebody).

You just need to change the background to a 9 patch drawable.

Here's how it looks like:
http://android-developers.blogspot.com/2011/04/customizing-action-bar.html

Source available here:
http://code.google.com/p/styled-action-bar/source/browse/trunk/res/drawable/actionbar_tab_bg.xml

9 patches available here:
http://code.google.com/p/styled-action-bar/source/browse/trunk/res/drawable-mdpi

I know this was really easy, but again, it might be useful so I'm just dropping the links here.

Solution 3

None of these solutions worked for me. I changed the colors of my tabs as follows:

This is in the themes.xml

<style name="MyApp" parent="android:style/Theme.Holo">
    <item name="android:actionBarTabTextStyle">@style/MyApp.ActionBar.MyTabStyle</item>
</style>

This is in styles.xml

<style name="MyApp.ActionBar.MyTabStyle" parent="android:style/Widget.Holo.ActionBarView_TabText">
    <item name="android:textColor">#00ff00</item>
</style>

This should make your tabs green.

Solution 4

I think that you can use:

<resources>
    <style name="MyTheme" parent="android:style/Theme.Holo.Light">
        <item name="android:actionMenuTextColor">@color/...</item>
    </style>
</resources>

Regards

Share:
19,663

Related videos on Youtube

xsx
Author by

xsx

Updated on September 07, 2020

Comments

  • xsx
    xsx over 3 years

    How can I change the color of the underline beneath the tabs? It's currently the light blue, and I can't find any resources on how to change this for Android 3.0.

    Additionally, I'd like to change the text color for the menu items that show up on the right of the ActionBar as a result of: android:showAsAction="ifRoom|withText"

    Anyone know how to change these?

  • xsx
    xsx about 13 years
    I'm using those successfully to adjust the tabs, but what I'm looking for currently is a way to do the same for the menu items on the right side of the ActionBar. I haven't found any style that mentions those menu items and the styles for the tabs don't have any effect on those. Edit -- sorry, I should also say that I think you're on point for the first part of my question. Thanks!
  • Paresh Mayani
    Paresh Mayani over 11 years
    What is the equivalent of android:style/Widget.Holo.ActionBarView_TabText because Holo is not there in lower SDK? FYI, i have integrated ActionBarSherLock library to make actionbar compatible with lower sdk.
  • Karthick
    Karthick about 11 years
    How can I set this property progrmatically.?

Related