Jeffrey
Jeffrey

Reputation: 4650

How to change the PagerTabStrip tab text color

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

Upvotes: 0

Views: 816

Answers (1)

Amir
Amir

Reputation: 16587

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>

Upvotes: 0

Related Questions