Skip to content

Instantly share code, notes, and snippets.

@gajerarajnit
Created October 3, 2017 10:13
Show Gist options
  • Save gajerarajnit/fda711b7062e63e7ac9789722cf7ed0d to your computer and use it in GitHub Desktop.
Save gajerarajnit/fda711b7062e63e7ac9789722cf7ed0d to your computer and use it in GitHub Desktop.
Apply custom fonts to textview....
public class CustomTypeFaceTextViewRegular extends TextView {
public TextViewRegular(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
applyCustomFont(context);
}
public TextViewRegular(Context context, AttributeSet attrs) {
super(context, attrs);
applyCustomFont(context);
}
public TextViewRegular(Context context) {
super(context);
applyCustomFont(context);
}
private void applyCustomFont(Context context) {
setTypeface(FontCache.getTypeface("Custom-font-Regular.ttf", context));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment