0

can anyone tell me how to have different color for different tab or atleast different color for current tab and unselected tab. I tried to change the tab text color programmatically but it changes all the tab text color. I could change the opacity of child tab using this code pagerTabStrip.getChildAt(0).setAlpha(.5f); Likewise is there any code to change the child tab text color

Jeffrey Rajan
  • 4,391
  • 4
  • 27
  • 37

1 Answers1

0

In your xml of pagerTabStrip define pstsTabTextColor attribute:

<com.astuetz.PagerSlidingTabStrip
    android:background="@color/gray_lightest"
    android:id="@+id/vp_indicator"
    android:layout_width="match_parent"
    android:layout_height="48dp"
    app:pstsTabTextColor="@drawable/switcher_indicator_text_selector"/>

Then in your drawable add following code for switcher :

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:color="@color/colorAccent" android:state_pressed="true" />
    <item android:color="@color/colorAccent" android:state_selected="true" />
    <item android:color="#65686D" />
</selector>
Amir
  • 16,067
  • 10
  • 80
  • 119