Custom unselected tab text color in SlidingTabLayout

房东的猫 提交于 2019-12-04 14:00:01
Sandra

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="http://schemas.android.com/apk/res/android">
    <item android:color="@android:color/selected" android:state_selected="true" />
    <item android:color="@android:color/unselected" />
</selector>

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).

skywall

Sandra's approach didn't work for me, because setSelected() is not called for specific view. My solution here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!