Skip to content

Instantly share code, notes, and snippets.

@jackmahoney
Created February 24, 2014 04:06
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jackmahoney/9181787 to your computer and use it in GitHub Desktop.
Save jackmahoney/9181787 to your computer and use it in GitHub Desktop.
Set custom font on an android custom textview. Untested code, be sure to test.
public class TextHelper{
private static TypeFace typeface = null;
public static void setTypeface(Context context, TextView textview){
if(this.typeface == null){
this.typeface = Typeface.createFromAsset(context.getAssets(), "Helvetica_Neue.ttf");
}
textview.setTypeface(face);
}
}
public class FontTextView extends TextView {
public FontTextView(Context context) {
super(context);
TextHelper.setTypeface(context, this);
}
}
@shahrukhbaig786
Copy link

shahrukhbaig786 commented Mar 26, 2018

Great !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment