Is it possible to set the font for all the TextViews in a activity? I can set the font for a single textView by using:
TextView tv=(TextView)findViewByI
Best answers
1. Setting custom font for one textView
Typeface typeface = Typeface.createFromAsset(getContext().getAssets(), "Fonts/FontName.ttf");
textView.setTypeface (typeface);
2. Setting custom font for all textViews
Create a JavaClass like below
public class CustomFont extends android.support.v7.widget.AppCompatTextView {
public CustomFont(Context context) {
super(context);
init();
}
public CustomFont(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public CustomFont(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
private void init() {
Typeface tf = Typeface.createFromAsset(getContext().getAssets(), "fonts/FontName.ttf");
setTypeface(tf);
}
}
And in your xml page
...
/>
=>