我是使用带有PagerTabStrip的ViewPager,我需要设置自定义字体(typeface),但是PagerTabStrip没有setTypeFace函数!
以下是我的XML代码:
根据这个链接,我找到了一个可能解决我的问题的解决方案。
But我不明白它的意思。
我的布局是:
以下是我的XML代码:
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/viewPager"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<android.support.v4.view.PagerTabStrip
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/pagerTabStrip"
android:layout_gravity="top"
android:background="#FF0000"
android:textColor="#FFFFFF" />
</android.support.v4.view.ViewPager>
根据这个链接,我找到了一个可能解决我的问题的解决方案。
获取PagerTabStrip的子视图,并检查它是否是TextView的实例。如果是,则设置字体:
for (int i = 0; i < pagerTabStrip.getChildCount(); ++i) {
View nextChild = pagerTabStrip.getChildAt(i);
if (nextChild instanceof TextView) {
TextView textViewToConvert = (TextView) nextChild;
textViewToConvert.setTypeface(PUT_TYPEFACE_HERE)
}
}
But我不明白它的意思。
我的布局是:
我想将标题标签的字体样式更改为其他样式,如下所示: