Created
April 28, 2015 08:30
-
-
Save layerlre/5c57c2a081cd939a280a to your computer and use it in GitHub Desktop.
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 TextViewTH extends TextView { | |
public TextViewTH(Context context) { | |
super(context); | |
//mContext = context; | |
setFont(); | |
} | |
public TextViewTH(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
//mContext = context; | |
setFont(); | |
} | |
public TextViewTH(Context context, AttributeSet attrs, int defStyle) { | |
super(context, attrs, defStyle); | |
//mContext = context; | |
setFont(); | |
} | |
private void setFont() { | |
int style = Typeface.NORMAL; | |
try { | |
style = getTypeface().getStyle(); | |
} catch (Exception e) { | |
//e.printStackTrace(); | |
} | |
Typeface face; | |
if (style == Typeface.NORMAL) { | |
//face = Typeface.createFromAsset(getContext().getAssets(), "fonts/ThaiSansNeue-Black.ttf"); | |
face = Typeface.createFromAsset(getContext().getAssets(), "fonts/ThaiSansNeue-Light.ttf"); | |
} else if (style == Typeface.BOLD) { | |
//face = Typeface.createFromAsset(getContext().getAssets(), "fonts/ThaiSansNeue-Bold.ttf"); | |
face = Typeface.createFromAsset(getContext().getAssets(), "fonts/ThaiSansNeue-Black.ttf"); | |
// } else if (style == Typeface.ITALIC){ | |
// face = Typeface.createFromAsset(getContext().getAssets(), "fonts/ThaiSansNeue-Light.ttf"); | |
} else { | |
face = Typeface.createFromAsset(getContext().getAssets(), "fonts/ThaiSansNeue-ExtraBlod.ttf"); | |
} | |
this.setTypeface(face); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment