简体   繁体   中英

android: different ways to set fontFamily

I have this 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"/>

If I use android:fontFamily it doesn't set the right font. What is the difference between the android: and app: version. Also what happens when I set app:font="@font/lato_regular" ?

android namespace is used in order to access and use the attributes which are provided by the Android platform.

app namespace is used to access the custom attributes which are defined in the application scope.

The app namespace is not specific to a library, but it is used for all attributes defined in your app, whether by your code or by libraries you import, effectively making a single global namespace for custom attributes - ie, attributes not defined by the android system.

Based on this

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM