Created
November 4, 2016 16:55
-
-
Save raviyadav4875/2982cad770043d928f353d9fbd2db7dc to your computer and use it in GitHub Desktop.
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 TextViewCustom extends TextView { | |
private static final String TAG = TextViewCustom.class.getSimpleName(); | |
public TextViewCustom(Context context) { | |
super(context); | |
} | |
public TextViewCustom(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
parseAttributes(context, attrs); //I'll explain this method later | |
} | |
public TextViewCustom(Context context, AttributeSet attrs, int defStyle) { | |
super(context, attrs, defStyle); | |
parseAttributes(context, attrs); | |
} | |
private void parseAttributes(Context context, AttributeSet attrs) { | |
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CustomFont); | |
String customFont = typedArray.getString(R.styleable.CustomFont_font); | |
if (customFont != null && customFont.length() > 0) { | |
setTypeface(TypeFaceProvider.getTypeFace(context, customFont)); | |
} | |
typedArray.recycle(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment