This article describes how Android uses custom fonts. Share it for your reference, as follows:
1. Question:
As a beginner in Android, when I was making a game, I used TextView for the title of the game. Android only provides italic bold, but setting the font into the interface of the game will be better. How can I achieve it?
2. Solution:
Using custom fonts
Android Typeface sets fonts using TTF font files
We can put ttf font files in the program and set fonts using Typeface in the program.
The first step is to create a new fonts directory under the assets directory and put the ttf font file here.
The second step is to call in the program:
AssetManager mgr=getAssets();//Get AssetManagerTypeface tf=(mgr, "fonts/");//Get Typeface according to the path(tf);//Set fonts
Using android:textStyle="bold" in an XML file can set English to bold, but not Chinese to bold.
The way to set Chinese to bold is:
TextView tv = (TextView)findViewById(.TextView01); ().setFakeBoldText(true); //Chinese imitation "bold"--Set setFakeBoldText to true using TextPaint's imitation "bold" to set setFakeBoldText to true.
I hope this article will be helpful to everyone's Android programming design.