简体   繁体   中英

how add in Adroid Studio custom font, which reacts on bold automatically?

I added 3 kind of one font in folder font: regular, bold and light. But the problem is, that my application doesnt react on bold, only takes regular font. How to set this globally?

I guess you have to add font-family like that:

<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:android="http://schemas.android.com/apk/res/android">
    <font
        android:fontStyle="normal"
        android:fontWeight="400"
        android:font="@font/lobster_regular" />
    <font
        android:fontStyle="italic"
        android:fontWeight="400"
        android:font="@font/lobster_italic" />
</font-family>

After this you will be able to use this param on views:

android:fontFamily="@font/lobster"

from: https://developer.android.com/guide/topics/ui/look-and-feel/fonts-in-xml

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