2

I want to know how to change tab indicator color. I have tried multiple code but none is working, So please help me how to change default color? below code I am using :

actionBar.setStackedBackgroundDrawable(getResources()
                        .getDrawable(R.drawable.tab_selector));

tab_selector.xml

--> --> -->

<!-- Focused states -->
<item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/cab_background_top_example" />
<item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/cab_background_top_example" />

<!-- Pressed -->
<item android:state_selected="true" android:state_pressed="true" android:drawable="@color/tabcolor" />
<item android:state_pressed="true" android:drawable="@color/tabcolor" />

Mochamad Taufik Hidayat
  • 1,264
  • 3
  • 21
  • 32
Ashish Jain
  • 328
  • 2
  • 15

2 Answers2

0

make a custom actionbar. Use this http://jgilfelt.github.io/android-actionbarstylegenerator/

Ted
  • 116
  • 10
  • I have download custom actionbar but still not working.Do I need to use style, which I have downloaded ? – Ashish Jain May 12 '15 at 11:00
  • See this on how to use actionbar style generator http://java.dzone.com/articles/creating-custom-android-styles Also paste the generated folders accordingly in your project – Ted May 12 '15 at 11:32
0

Using style also you can do this (code is based on support-v7 library)

    <style name="MyAppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">

             <item name="android:actionBarTabStyle">@style/MyActionBarTabs</item> 
             <item name="actionBarTabStyle">@style/MyActionBarTabs</item>

    </style>

    <style name="MyActionBarTabs" parent="@style/Widget.AppCompat.ActionBar.TabView">

       <item name="android:background">@drawable/tab_selector</item>
        <item name="background">@drawable/tab_selector</item> 

    </style>

For more info visit Official Doc: Styling the Action Bar.

halfer
  • 19,824
  • 17
  • 99
  • 186
Bharatesh
  • 8,943
  • 3
  • 38
  • 67