其他分享
首页 > 其他分享> > 我在字体家族Android Studio中找不到sans-serif-medium

我在字体家族Android Studio中找不到sans-serif-medium

作者:互联网

我正在遵循版式指南和此链接

How to change fontFamily of TextView in Android

它说sans-serif-medium在Android 4.1 / 4.2 / 5.0上可用.

但是,当我尝试找到这些字体类型时,似乎找不到建议.为什么??

enter image description here

我需要下载该字体的ttf文件吗?

我编译的SDK是24.

解决方法:

为此,请使用Sans Serif字体.

在您的styles.xml文件中,定义字体的样式

<style name="roboto_regular_textview" parent="@android:style/Widget.TextView">
        <item name="android:fontFamily">sans-serif</item>
    </style>

    <style name="roboto_medium_textview" parent="@android:style/Widget.TextView">
        <item name="android:fontFamily">sans-serif</item>
        <item name="android:textStyle">bold</item>
    </style>

    <style name="roboto_light_textview" parent="@android:style/Widget.TextView">
        <item name="android:fontFamily">sans-serif-light</item>
    </style>

并在layout.xml文件中

<TextView
                style="@style/roboto_regular_textview"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:textColor="@color/black_text_color"
                android:textSize="30sp" />

标签:android-layout,android-typeface,android,textview
来源: https://codeday.me/bug/20191111/2020704.html