android开发可以在xml资源文件里设置自定义字体吗

2025-04-04 15:23:47
推荐回答(1个)
回答1:

这个在xml中设置字体只能是系统内置的几种字体,如monospace、sans、serif等,
设置方法:android:typeface="monospace"

但是要是想设置自定义的、放在assert目录下的字体的话,只能在代码中去设置了:如:
Typeface font=Typeface.createFromAsset(this.getAssets(),"fonts/YourCustomFont.ttf");
textView.setTypeface(font);