Skip to content

Instantly share code, notes, and snippets.

@sanjogshrestha
Created December 7, 2015 10:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sanjogshrestha/9d4a3535b36b8a754763 to your computer and use it in GitHub Desktop.
Save sanjogshrestha/9d4a3535b36b8a754763 to your computer and use it in GitHub Desktop.
Custom TextView in android
public class MyTextView extends TextView {
public MyTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
public MyTextView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public MyTextView(Context context)
{
super(context);
init();
}
private void init() {
Typeface tf = Typeface.createFromAsset(getContext().getAssets(),"roboto.TTF");
setTypeface(tf);
setTextColor(getResources().getColor(R.color.text_color));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment