Android: Font download and font replacement

Font download link

mirrors / Ice-Times / Android-ttf-download · GitCode

After downloading, there are more than a dozen fonts in it

 Use of fonts

It is introduced in the official documents

https://developer.android.com/guide/topics/resources/font-resource?hl=zh-cn

Let me briefly summarize

 

Create a new font folder in the res directory, add the required fonts to this folder, and rename it as needed.

Create a new lobster file

The content is as follows:

<?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/pop" />
    <font
        android:fontStyle="italic"
        android:fontWeight="400"
        android:font="@font/pop" />
</font-family>

use

        <TextView
            android:fontFamily="@font/lobster"
            ....
        />

achieve effect

 

 

Guess you like

Origin blog.csdn.net/title71/article/details/129884568