在SlidingTabLayout自定义未选定标签的文本颜色 [英] Custom unselected tab text color in SlidingTabLayout

查看:291
本文介绍了在SlidingTabLayout自定义未选定标签的文本颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在用的是 SlidingTabLayout 类显示卡在我的Andr​​oid应用程序。 我使用,我设置了 setCustomTabView 函数我的自定义选项卡视图。虽然我可以轻松地定制选定的选项卡文本颜色,我无法找到一个方法来定制未被选中的选项卡的文本颜色。的L ​​preVIEW文件,他们认为,它应该是#FFF 60%,我想使用完全相同的价值也。我看了看 SlidingTabLayout SlidingTabStrip 类,但无法弄清楚,我应该在哪里进行修改..也许我'已经错过了一些东西。如果有人有一个解决方案,请分享。

I am using the SlidingTabLayout class to display tabs in my Android application. I'm using my custom tab view which I set with the setCustomTabViewfunction. 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 #fff 60%, and I want to use that exact same value also. I looked at the SlidingTabLayout and SlidingTabStrip classes, but could not figure out where should I make modifications.. Maybe I've missed something. If someone has a solution, please share.

推荐答案

答案竟然是很简单,其实..我不知道为什么我没有想到它越快。对于每个人都在想,你们谁应该简单地在res /颜色文件夹中创建 tab_text.xml ,与内容:

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>

,然后设置定义的XML(<$ C C $> tab_text.xml )的自定义选项卡视图文字颜色属性(在我的情况下,自定义视图是一个简单的的TextView

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)

这篇关于在SlidingTabLayout自定义未选定标签的文本颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆