There are usually two types of font settings:
1: Set directly in XML
Android:textstyle= "Bold" android:typeface
2: Set in the form of Java code
Use the typeface class in the Android SDK to define fonts, which can be set by common font type names, such as setting Italic:
TextView Quehuo = (TextView) Findviewbyid (R.id.quehuo);//Set style TextView for the fonts displayed in Quehuo.settypeface (typeface.sans_ SERIF, typeface.italic);
commonly used font type name there:
* Typeface.default//General font type
* Typeface.default_bold//blackbody font type
* Typeface.monospace//equal-width font type
* Typeface.sans_serif//sans SERIF font type
* Typeface.serif//serif Font type
In addition to font type settings, you can also set font styles for font types, such as bold:
commonly used font style name also:
* Typeface.bold//Bold
* Typeface.bold_italic//Bold Italic
* Typeface.italic//Italic
* Typeface.normal//General
TextView Quehuo = (TextView) Findviewbyid (R.id.quehuo); // Sets the style Quehuo.settypeface (Typeface.sans_serif, Typeface.italic) for the font displayed for TextView ;
There are two types of settypeface in the above code:
1. Set font type only: Settypeface (Typeface tf): The meaning of the parameter is to set the font type
2, Settypeface (Typeface tf,int style): The first parameter means to set the font type, the second parameter means to set the font style.
The style and thickness of the font that the Android development dynamically sets