第一种方法 在代码中设置 但是前提是 需要在 assets文件夹下边建立一个 fonts的子文件夹
在onCreaty里边进行
Typeface fontFace = Typeface.createFromAsset(getAssets(),
"fonts/CHAT.TTF");
TextView customer_1 = (TextView) findViewById(R.id.customer_1);
customer_1.setTypeface(fontFace);
第二种方法 自定义一个TextView
public class MyTextView extends TextView{
public MyTextView(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);
}
/**
* 初始化字体
* @param context
*/
private void init(Context context) {
//设置字体样式
setTypeface(Typeface.createFromAsset(context.getAssets(), "fonts/CHAT.TTF"));
}
}
直接在布局中引用就好了
第三种方法呢 想起来了在补充