原文链接 AS创建assets文件夹与字体
方法一
// 设置浪漫雅圆字体 字体格式要为ttf
Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/lmyy.ttf");
mTv.setTypeface(typeface);
方法二
// 另一种思路
public class CustomTextView extends TextView{
public CustomTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public void setTypeface(Typeface tf) {
Typeface typeface = Typeface.createFromAsset(getContext().getAssets(), "fonts/lmyy.ttf");
super.setTypeface(typeface);
}
}