Sandra Sandra - 1 year ago 81
Android Question

Custom unselected tab text color in SlidingTabLayout

I am using the

class to display tabs in my Android application.

I'm using my custom tab view which I set with the
function. Although I can easily customize the selected tab text color, I can not find a way to customize the text color of the unselected tab. In the L preview documentation they suggest that it should be
60%, and I want to use that exact same value also. I looked at the
classes, but could not figure out where should I make modifications.

Answer Source

The answer turned out to be quite simple, actually.. I don't know why I did not think of it sooner..

For everybody who wonder, you should simply create tab_text.xml in the res/colors folder, with content:

<selector xmlns:android="">
    <item android:color="@android:color/selected" android:state_selected="true" />
    <item android:color="@android:color/unselected" />

And then set the defined xml (tab_text.xml) to the textColor attribute of the custom tab view (in my case the custom view is a simple TextView).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download