I'm using the new TabLayout from the Android Design library. I managed to set the textcolor statelist using tabLayout.setTabTextColors(colorstatelist)
How can i achieve the same using styles.xml?
I'm using the new TabLayout from the Android Design library. I managed to set the textcolor statelist using tabLayout.setTabTextColors(colorstatelist)
How can i achieve the same using styles.xml?
Here is snippet code to override text style and selected text color
And here is snippet code for layout
You just have to override
android:textAppearance
style. Because TabLayout use textAppearance. here is the small snippet code of style.And if you dont want to reference from your Apptheme you can directly specify to TabLayout using Below snippet.
All the answers above are correct but I just think its better to override the default styles and only change the specific element you want to change. Example below will make the text bold:
Then..,
For custom tabs we have to override the following : 1) app:tabTextColor //for_unselected_text"
2) tabSelectedTextColor // for selected tab color 3) tabIndicatorColor // color for tab indicator
tab_text_color.xml
Via XML attributes:
Additionally, there are attributes like tabIndicatorColor or tabIndicatorHeight for further styling.
In code:
Since this old way is deprecated as of API 23, the alternative is: