【问题标题】:android: different ways to set fontFamilyandroid:设置fontFamily的不同方法
【发布时间】:2020-08-06 17:07:00
【问题描述】:

我有这个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" 时会发生什么?

【问题讨论】:

  • 'preloaded_fonts.xml'文件夹中有你的字体吗?

标签: android font-family


【解决方案1】:

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

app 命名空间用于访问应用范围内定义的自定义属性。

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

基于this

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-01-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-06
    • 2016-01-10
    相关资源
    最近更新 更多