Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the color of tab 'underbar' in actionbarsherlock

Ok i'm loosing more sanity then ever. I can't find/understand how to style the damn thing. I managed to change the background of the tab itself but I can't cahnge the color of the bar under the selected tab.

How to change it from blue to something.

My styles.xml unfortunately I have very bad understanding of how it works

<?xml version="1.0" encoding="utf-8"?>
<resources>


    <style name="Theme.Styled" parent="Theme.Sherlock.Light">
        <item name="actionBarTabStyle">@style/Widget.Styled.ActionBarTab</item>
        <item name="android:actionBarTabStyle">@style/Widget.Styled.ActionBarTab</item>

        <item name="actionBarTabBarStyle">@style/Widget.Styled.ActionBarTabBar</item>
        <item name="android:actionBarTabBarStyle">@style/Widget.Styled.ActionBarTabBar</item>

        <item name="actionBarTabTextStyle">@style/myText</item>
        <item name="android:actionBarTabTextStyle">@style/myText</item>


    </style>

    <style name="Widget.Styled.ActionBarTab" parent="Widget.Sherlock.Light.ActionBar.TabView">
    <!--    <item name="background">@drawable/startbcg</item>
        <item name="android:background">@drawable/startbcg</item>
        <item name="backgroundSplit">@drawable/bg_striped_split</item>
        <item name="android:backgroundSplit">@drawable/bg_striped_split</item>
    -->
    </style>


    <style name="Widget.Styled.ActionBarTabBar" parent="Widget.Sherlock.Light.ActionBar.TabBar">

        <item name="background">@drawable/startbcg</item>
        <item name="android:background">@drawable/startbcg</item>
         <item name="backgroundSplit">@drawable/bg_striped_split</item>
        <item name="android:backgroundSplit">@drawable/bg_striped_split</item>

    </style>

    <style name="myText" parent="Widget.Sherlock.Light.ActionBar.TabText">
        <item name="android:textAppearance">@android:style/TextAppearance.Medium</item>
        <item name="android:textColor">@android:color/primary_text_dark</item>
        <item name="android:textSize">10sp</item>


    </style>
<style name="myTextInv" parent="Widget.Sherlock.Light.ActionBar.TabText.Inverse">
        <item name="android:textAppearance">@android:style/TextAppearance.Medium</item>
        <item name="android:textColor">@android:color/primary_text_dark</item>
        <item name="android:textSize">10sp</item>


    </style>
</resources>

Bonus question: where I can find what properties (like background) certain stuff has.

like image 397
user1317422 Avatar asked Jun 30 '12 11:06

user1317422


Video Answer


1 Answers

Use ActionbarStyleGenerator to style the Actionbar. This is by far the simplest and most intuitive way.

How to:

  1. Use the UI to select colors for different items
  2. Once done click on "DOWNLOAD .ZIP"
  3. The ZIP file contains resource files that you have to copy in your project res/layout and res/drawableXXXX folders
like image 135
Andrea Motto Avatar answered Nov 02 '22 10:11

Andrea Motto