参考:https://www.likecs.com/show-204509997.html //通过stylehttps://www.jianshu.com/p/439842651419 //webView app本地字体
当然上面是通过style的方式 也可以通过style全局设置字体 (这作用于整个app)
也可以自定义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);
}
}