Skip to content

Instantly share code, notes, and snippets.

@devrath
Created December 15, 2015 04:59
Show Gist options
  • Select an option

  • Save devrath/65ea63c49a45bd8f0b68 to your computer and use it in GitHub Desktop.

Select an option

Save devrath/65ea63c49a45bd8f0b68 to your computer and use it in GitHub Desktop.
Loading a custom font for a TextView from a custom class
public class CustomTV_Sam_bold extends TextView {
Context context;
public CustomTV_Sam_bold(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
this.context = context;
init();
}
public CustomTV_Sam_bold(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public CustomTV_Sam_bold(Context context) {
super(context);
init();
}
public void init() {
Typeface tf = Typeface.createFromAsset(getContext().getAssets(), "SamsungSharpSans-Bold.ttf");
setTypeface(tf);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment