android - how to change the font of PagerTabStrip -


i'm using viewpager pagertabstrip , need set custom fonts (typeface) , there no .settypeface function pagertabstrip!

here xml code:

 <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> 

according : link
found solution maybe solve problam...

get child views of pagertabstrip , check if instance of textview. if is, set typeface:

for (int = 0; < pagertabstrip.getchildcount(); ++i) { view nextchild = pagertabstrip.getchildat(i); if (nextchild instanceof textview) {    textview textviewtoconvert = (textview) nextchild;    textviewtoconvert.settypeface(put_typeface_here) } } 

but dont understand means...!

my layout :

enter image description here

i want change title tab font style,like below:

enter image description here

thank can provide

you need create style text, , use android:textappearance attribute...

something this:

 <style name="pagertabstriptext">      <item name="android:textstyle">italic</item>  </style> 

your pagertabstrip xml this:

<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:textappearance="@style/pagertabstriptext" /> 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -