Created
December 7, 2015 10:01
-
-
Save sanjogshrestha/9d4a3535b36b8a754763 to your computer and use it in GitHub Desktop.
Custom TextView in android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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