使用半粗体样式的 Android 可下载字体

amo*_*the 5 android android-fonts android-support-library google-play-services android-downloadable-fonts

我正在使用以下链接中给出的谷歌可下载字体

https://developer.android.com/guide/topics/ui/look-and-feel/downloadable-fonts.html

我想使用 Montserrat 字体样式半粗体,但该选项在 android 中不存在

同样在下面的链接中有样式半粗体任何想法如何做到这一点

https://fonts.google.com/specimen/Montserrat

以下是我添加字体系列后的 textview xml

 <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="5dp"
        android:layout_marginLeft="8dp"
        android:layout_marginTop="8dp"
        android:fontFamily="@font/montserrat"
        android:text="@string/address"
        android:textAllCaps="false"
        android:textColor="@color/title_light_color"
        android:textSize="10sp"
        android:textStyle="bold" />
Run Code Online (Sandbox Code Playgroud)

Ram*_*mbu 2

您可以在这里下载所有类型的字体montserrat

https://github.com/google/fonts/tree/master/ofl/montserrat

https://github.com/google/fonts/blob/master/ofl/montserrat/Montserrat-SemiBold.ttf

添加到您的res/font文件夹中使用这个

android:fontFamily="@font/Montserrat-SemiBold"
Run Code Online (Sandbox Code Playgroud)

希望能帮助到你