In my app I'm using a ViewPager with a PagerTabStrip and I need to set custom fonts to my widgets. To set a font for a Button
or a TextView
I just extend the class and set a typeface.
public class MyButton extends Button {
public MyButton(Context context) {
super(context);
initCustomFont();
}
public MyButton(Context context, AttributeSet attrs) {
super(context, attrs);
initCustomFont();
}
public MyButton(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
initCustomFont();
}
private void initCustomFont() {
if(!isInEditMode()) {
Typeface tf = Typeface.createFromAsset(getContext().getAssets(), "fonts/boton_regular.ttf");
setTypeface(tf);
}
}
}
But I can't use this method for a PagerTabStrip
. Is there another way to set a typeface that can be used with PagerTabStrip
?