我有类似的问题和类似的解决方案:
1)尺寸
在xml中,您具有TabLayout,
<android.support.design.widget.TabLayout
...
app:tabTextAppearance="@style/CustomTextStyle"
...
/>
然后风格
<style name="CustomTextStyle" parent="@android:style/TextAppearance.Widget.TabWidget">
<item name="android:textSize">16sp</item>
<item name="android:textAllCaps">true</item>
</style>
如果您不希望大写的字符在“ android:textAllCaps”中输入false
2)选中或未选中的标签的文本颜色,
TabLayout tabLayout = (TabLayout) view.findViewById(R.id.tabs);
tabLayout.setupWithViewPager(viewPager);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
tabLayout.setTabTextColors(getResources().getColorStateList(R.color.tab_selector,null));
} else {
tabLayout.setTabTextColors(getResources().getColorStateList(R.color.tab_selector));
}
然后在res / color / tab_selector.xml中
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/white" android:state_selected="true" />
<item android:color="@color/white" />