如何更改所选标签标题颜色 [英] How to change selected tab title color

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

问题描述

我需要改变的选中的标签颜色在我的选项卡活动。

I need to change selected tab color in my tab activity.

例如,所选项目的文本颜色必须是#cea939 ,和未选定项目的颜色必须是#d7ba60 。我应该怎么做才能改变这种状况?其实,我试图文字颜色值添加到 apptheme_tab_indicator.xml - 但没有结果。顺便说一句,我用 AppCompat 。如果有一个解决方案,它是如何发生变化的风格风格-V21

For example, selected item text color must be #cea939, and unselected items colors have to be #d7ba60. What should I do to change that? Actually, I tried to add textColor value to apptheme_tab_indicator.xml - but no result. By the way, I use AppCompat. And if there is a solution, how does it vary for styles and styles-v21?

推荐答案

您可以检查我的答案后<一href="http://stackoverflow.com/questions/28881599/how-to-change-viewpager-tab-colour-dynamically/28883927#28883927">How动态地改变Viewpager标签颜色,使用自定义视图选项卡,和恰克的背景颜色设置codeS文字颜色设置​​:

You can check my answer for the post How to change Viewpager tab colour dynamically?, use custom view for tabs, and chage the codes of background color setting to text color setting:

Tab selectedTab = yourActionBar.getSelectedTab();
View tabView = selectedTab.getCustomView();
TextView text = (TextView)tabView.findViewById(R.id.your_text_id);  
text.setColor(your_text_color);

希望这有助于!

Hope this help!

这篇关于如何更改所选标签标题颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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