One, custom fonts
1.android typeface setting fonts using TTF font files
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 place the TTF font file here.
In the second step, the program calls:
Assetmanager mgr=getassets ();//Get Assetmanagertypeface Tf=typeface.createfromasset (Mgr, "Fonts/ttf.ttf");// Get Typefacetv=findviewbyid (R.id.textview) according to the path; Tv.settypeface (TF);//Set Font
2. Use the android:textstyle= "bold" in the XML file to set the English to bold, but you cannot set the Chinese to bold,
The way to set Chinese to bold is:
TextView TV = (TextView) Findviewbyid (R.ID.TEXTVIEW01); Tv.getpaint (). Setfakeboldtext (true);//Chinese Imitation "bold"--Setfakeboldtext to True using Textpaint's faux "bold" setting.
Note: Some fonts in Chinese are not valid, although they will not be error, but not Chinese. Second, use Roboto since Android4.0 after the default font is used Roboto, the following describes how to use:
android:fontfamily= "Sans-serif"//Roboto regularandroid:fontfamily= "sans-serif-light"//Roboto Lightandroid: fontfamily= "sans-serif-condensed"//Roboto condensedandroid:fontfamily= "Sans-serif-thin"//Roboto Thin (Android 4.2) In combination withandroid:textstyle= "Normal|bold|italic"
Available parameters:
Regular
Italic
Bold
Bold-italic
Light
Light-italic
Thin
Thin-italic
Condensed Regular
Condensed italic
Condensed Bold
Condensed Bold-italic
Android font settings, Roboto font use