Created
January 26, 2017 06:33
-
-
Save talhahasanzia/564ba68a4187a6b6d7151000a756557d to your computer and use it in GitHub Desktop.
Custom font in a predefined textview
This file contains hidden or 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 CustomFontTextView extends TextView | |
{ | |
public CustomFontTextView(Context context, AttributeSet attrs, int defStyle) { | |
super(context, attrs, defStyle); | |
init(); | |
} | |
public CustomFontTextView(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
init(); | |
} | |
public CustomFontTextView(Context context) { | |
super(context); | |
init(); | |
} | |
private void init() { | |
if (!isInEditMode()) { | |
Typeface tf = Typeface.createFromAsset(getContext().getAssets(), "Sans-Bold.ttf"); | |
setTypeface(tf); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment