Get the App
SLTechnology News&Howtos  ›  Development  › 

How to set fonts in Android

Shulou Source: shulou.com Published: 2022-05-31 21:46:57 10月28日 Update

This article focuses on "how to set fonts in Android". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to set fonts in Android.

1. Set the font in the Android XML file

You can use Android:typeface, such as android:typeface= "monospace". In this example, we display android:text= "Hello, World!" in Activity in four ways, which are "Sans", "serif", "monospace" and the system default mode (sans is used by default after testing). There are differences in English fonts, but there seems to be no difference in Chinese fonts. The XML file is as follows:

Java Code:

Tags: Font file character special content method ellipsis system Chinese English hello code example font actual difference text line letter length Chinese Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi NVidia Microsoft Apple Shulou Tech Info