Android 8.0(26)引入的新特性,字體資源化。小於此版本的需要引入surpport->=26。
具體使用,xml中
android:font="@font/huawenxinsong"
java中
R.font.myfont 和其他資源(圖片)使用類似
Typeface typeface = getResources().getFont(R.font.****);
tv.setTypeface(typeface);
或者直接使用
Typeface t= ResourcesCompat.getFont(getApplicationContext(),R.font.***);
font的項目存放位置,res--font文件夾,將你的font拷貝到此文件夾。