So I\'d like to change the android:fontFamily
in Android but I don\'t see any pre-defined fonts in Android. How do I select one of the pre-defined ones? I don\'
If you want to use a TextView in so many places with same font family, extend the TextView class and set your font like this:-
public class ProximaNovaTextView extends TextView {
public ProximaNovaTextView(Context context) {
super(context);
applyCustomFont(context);
}
public ProximaNovaTextView(Context context, AttributeSet attrs) {
super(context, attrs);
applyCustomFont(context);
}
public ProximaNovaTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
applyCustomFont(context);
}
private void applyCustomFont(Context context) {
Typeface customFont = FontCache.getTypeface("proximanova_regular.otf", context);
setTypeface(customFont);
}
}
And then use this custom class in xml for the TextView like this:-