首页 > 解决方案 > android:设置fontFamily的不同方法

问题描述

我有这个TextView

<androidx.appcompat.widget.AppCompatTextView
            android:id="@+id/tv"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginTop="12dp"
            android:contentDescription="...."
            android:text="text"
            android:textAllCaps="true"
            android:textColor="@color/black4"
            android:textSize="16sp"
            app:fontFamily="@font/lato_regular"/>

如果我使用android:fontFamily它不会设置正确的字体。android:app:版本有什么区别。当我设置时会发生什么app:font="@font/lato_regular"

标签: androidfont-family

解决方案


android命名空间用于访问和使用 Android 平台提供的属性。

app命名空间用于访问在应用程序范围中定义的自定义属性。

应用程序命名空间不是特定于库,而是用于应用程序中定义的所有属性,无论是由您的代码还是由您导入的库,有效地为自定义属性创建一个全局命名空间 - 即,未由 android 定义的属性系统。

基于


推荐阅读