不能改变TabLayout活动的文本颜色 [英] Cannot change active text color on TabLayout
问题描述
我想风格标签在android.support.design.widget.TabLayout我无法选择的选项卡的颜色变化,它总是设置为textColorPrimary在我的应用程序的主题,但我需要他们不同颜色。
I am trying to style tabs in an android.support.design.widget.TabLayout I can not get the selected tab color to change, it is always set to the textColorPrimary in my app theme, but I need them to be different colors.
我曾尝试在应用到TabLayout styles.xml设定值,但我读了您不能更改活动标签的文本颜色这样一来,虽然我可以改变未选择的选项卡文本颜色。我也曾尝试:
I have tried setting values in styles.xml that applies to TabLayout, but I read you can not change active tab text color this way, though I can change unselected tab text colors. I have also tried:
tabLayout.setTabTextColors(getResources().getColorStateList(R.color.selector));
和
tabLayout.setTabTextColors(R.color.Green, R.color.Blue);
是否有可能重写选定的选项卡文本颜色?
Is it possible to override the selected tab text color?
推荐答案
编辑:得到它的工作,
tabLayout.setTabTextColors(getResources().getColorStateList(R.color.selector));
需要把它称为附着到视图寻呼机之前
needed called before it was attached to the view pager
这篇关于不能改变TabLayout活动的文本颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!