Android字体的设置有以下方法:
1、直接在代码设置
Typeface customFont = Typeface.createFromAsset(this.getAssets(), "1.ttf");
TextView textview1= (TextView) findViewById(R.id.activity_main_header);
textview1.setTypeface(customFont);
2、自定义控件
public class MyTextView extends TextView {
public MyTextView (Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public MyTextView (Context context, AttributeSet attrs) {
super(context, attrs);
}
public MyTextView (Context context) {
super(context);
}
public void setTypeface(Typeface tf, int style) {
super.setTypeface(Typeface.createFromAsset(getContext().getAssets(), "1.tff"));
}
}