我正在尝试新的工作TabLayout
来自android设计库。
我想将选项卡文本更改为自定义字体。而且,我尝试搜索一些相关的样式TabLayout
,但最终结果是this.
请指导如何更改选项卡文本字体。
如果您正在使用TabLayout
如果您想更改字体,则必须向之前的解决方案添加一个新的 for 循环,如下所示:
private void changeTabsFont() {
ViewGroup vg = (ViewGroup) tabLayout.getChildAt(0);
int tabsCount = vg.getChildCount();
for (int j = 0; j < tabsCount; j++) {
ViewGroup vgTab = (ViewGroup) vg.getChildAt(j);
int tabChildsCount = vgTab.getChildCount();
for (int i = 0; i < tabChildsCount; i++) {
View tabViewChild = vgTab.getChildAt(i);
if (tabViewChild instanceof TextView) {
((TextView) tabViewChild).setTypeface(Font.getInstance().getTypeFace(), Typeface.NORMAL);
}
}
}
}
请参阅使用 sherlock 更改操作栏选项卡中的字体样式
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)