方法一,在xml中添加:android:fontFamily="@string/font_family_medium"
方法二,在代码中添加:textview.setTypeface(Typeface.createFromAsset(mContext.getAssets(), "DINMittelschrift.otf"));
注意,方法一需要配合使用的font_family.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--roboto light 细体-->
<string name="font_family_light">sans-serif-light</string>
<!--roboto medium (android 5.0)中等加粗字体-->
<string name="font_family_medium">sans-serif-medium</string>
<!--roboto regular 常规(系统默认)-->
<string name="font_family_regular">sans-serif</string>
<!--roboto condensed-->
<string name="font_family_condensed">sans-serif-condensed</string>
<!--roboto black (android 4.2)-->
<string name="font_family_black">sans-serif-black</string>
<!--roboto thin 超细体-->
<string name="font_family_thin">sans-serif-thin</string>
</resources>