简体   繁体   中英

How to use system custom fonts in Android Studio

In some devices, there is a option to customize the font in the device settings. Also, some devices may not use the Roboto font. How can I ensure that my app can use the system font, instead of a fixed font in my app? I am using Kotlin 1.3 on Android Studio 3.5.

Don't use custom fonts in your views like -

<TextView
    ....
    android:fontFamily="@fonts/Arial"
    ....
 />

or by TypeFace or by style like -

<style name="Regular">
        <item name="android:fontFamily">@font/dancing_script</item>
 </style>

If you set a custom font manually than your app will use that custom font in every device. But if you don't use a custom font than device's font is applied on your views.

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