android - 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"
?
解决方案
android
命名空间用于访问和使用 Android 平台提供的属性。
app
命名空间用于访问在应用程序范围中定义的自定义属性。
应用程序命名空间不是特定于库,而是用于应用程序中定义的所有属性,无论是由您的代码还是由您导入的库,有效地为自定义属性创建一个全局命名空间 - 即,未由 android 定义的属性系统。
基于此
推荐阅读
- android - 来自 Qt Android C++ Firebase 的哄骗日志信息(通知不起作用)
- amazon-web-services - 从 AWS CloudFront 中删除 Cache-Control 标头?
- c++ - 打印此矩阵的 if 语句是什么
- javascript - 在 JavaScript 或 Typescript 中删除数组数组中的对象
- swift - 如何降低或提高 Spotify SDK Swift 中的音乐音量
- promise - 如何将 WebExtensions 通知包装在 Promise 中?
- regex - 从字符串中提取一个单词
- vim - 快速修复窗口无法打开
- c# - 从字符串数组创建对象数组中的对象
- redirect - NestJS - 检查失败时从守卫重定向用户