参考:https://www.likecs.com/show-204509997.html //通过stylehttps://www.jianshu.com/p/439842651419 //webView app本地字体
当然上面是通过style的方式 也可以通过style全局设置字体 (这作用于整个app)
![](https://img-blog.csdnimg.cn/img_convert/c19ef420fcb9b1fbb83524ab04e724da.webp?x-oss-process=image/format,png)
image.png
![](https://img-blog.csdnimg.cn/img_convert/ff3f9666685f7eefd09b7318d000246b.webp?x-oss-process=image/format,png)
image.png
也可以自定义TextView
public class HarmonSansSCMediumTextView extends AppCompatTextView {
public HarmonSansSCMediumTextView(Context context) {
super(context);
init(context);
}
public HarmonSansSCMediumTextView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
init(context);
}
public HarmonSansSCMediumTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context);
}
private void init(Context context) {
Typeface customFont = FontCache.getTypeface("fonts/harmony.ttf", context);
setTypeface(customFont);
}
}