(创建于2016/12/20)
1,自定义一个TextView
public class CustomTextView extends TextView {
public CustomTextView(Context context) {
super(context);
init(context);
}
public CustomTextView(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);
}
public CustomTextView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context);
}
/**
* 设置字体
* @param context
*/
private void init(Context context){
AssetManager assets = context.getAssets();
Typeface font = Typeface.createFromAsset(assets, "fonts/Lobster-1.4.otf");
setTypeface(font);
}
}
2,在assets目录中放入字体文件