使用“font”资源文件在Android中不更改字体

时间:2017-09-06 16:36:34

标签: android android-resources android-fonts

按照在Android Studio 3中使用字体的新方法,我在res中添加了字体资源文件夹,并在其中添加了.ttf字体,然后在xml文件中引用它们,如下所示:

                    <TextView
                    android:id="@+id/tv_about"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="8dp"
                    android:text="@string/about_info"
                    android:textColor="@color/tin"
                    android:textSize="23sp"
                    android:fontFamily="@font/diana" />

编译正常但不起作用,字体不会改变。

1 个答案:

答案 0 :(得分:0)

您需要定位API级别26+(Oreo)和支持库26.0.0+才能在res / font中应用字体。