android:使用自定义字体

一,添加字体文件

在res目录下创建font目录,
然后把字体文件复制到此目录下,
注意:字体文件的文件名请使用英文小写字符

二,代码:

xml:

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="128dp"
        android:layout_marginTop="68dp"
        android:layout_marginEnd="128dp"
        android:layout_marginBottom="645dp"
        android:fontFamily="@font/fzfwzzay"
        android:text="一点浩然气,\n千里快哉风"
        android:textSize="42sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

三,测试效果:

posted @ 2025-05-24 17:55  刘宏缔的架构森林  阅读(42)  评论(0)    收藏  举报