textView.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/yahei.ttf"));
import android.content.Context;
import android.graphics.Typeface;
import android.widget.TextView;
public class Fonter {
public static void format(Context context, TextView textView){
textView.setTypeface(Typeface.createFromAsset(context.getAssets(), "fonts/yahei.ttf"));
}
}
本文介绍了一种在Android应用中为TextView组件设置微软雅黑字体的方法。通过使用Typeface类和getAssets()方法从应用资源文件夹中加载字体文件,可以轻松实现自定义字体的设置。
713

被折叠的 条评论
为什么被折叠?



