Two ways to control font settings
Common font type names are:
Typeface.default//General font type
Typeface.default_bold//Blackbody font type
Typeface.monospace//equal-width font type
Typeface.sans_serif//sans SERIF Font type
The commonly used font style names are:
Typeface.bold//Bold
Typeface.bold_italic//Coarse italic
Typeface.italic//Italic
Typeface.normal//General
1. Set in XML.
Use Android:typeface to set:
Android:typeface= "Sans"
2. In the Java program:
EG1:
Typeface font = typeface.create (Typeface.sans_serif, typeface.bold);
P.settypeface (font);
EG2:
String familyname = "Song Body";
Typeface font = typeface.create (familyname,typeface.bold);
P.settypeface (font);
Using external fonts
1. First, copy the font file you want to use under the Fonts directory under assets.
2. The code is as follows:
privatevoidmySetTypeFace() { // TODO Auto-generated method stub //从assert中获取有资源,获得app的assert,采用getAserts(),通过给出在assert/下面的相对路径。在实际使用中,字体库可能存在于SD卡上,可以采用createFromFile()来替代createFromAsset。 "fonts/HanYi.ttf"); //title是之间定义的控件 title.setTypeface(face); }
Android font Settings-typeface explanation