The examples in this article describe how Android uses custom fonts. Share to everyone for your reference, specific as follows:
First, the question:
As an Android beginner, in doing a game, the title of the game I use is textview,android only provide italic bold, but the font set into italics game interface will be better, how to achieve.
Second, the solution:
Using custom Fonts
android typeface use TTF font file to set fonts
We can put the TTF font file in the program and use typeface to set the font in the program.
The first step is to create a new fonts directory under the assets directory and put TTF font files here.
In the second step, the program calls:
Assetmanager mgr=getassets ()//Get Assetmanager
typeface Tf=typeface.createfromasset (Mgr, "Fonts/ttf.ttf"); Get typeface
Tv.settypeface (TF) based on path;//Set Font
Use android:textstyle= "Bold" in an XML file to set English bold, but you cannot set Chinese to bold.
The way to set Chinese in bold is to:
TextView TV = (TextView) Findviewbyid (r.id.textview01);
Tv.getpaint (). Setfakeboldtext (true);
Chinese imitation "bold"--use textpaint faux bold to set Setfakeboldtext to true.
I hope this article will help you with the Android program.