It's embarrassing. Android font settings
Android support for Chinese fonts is not good ~ ~ need to add the appropriate font library
(1) Creating layout layouts
Create a linear layout
LinearLayout linearlayout=Newlinearlayout (this);
Set the linear layout to the vertical direction
Linearlayout.setorientation (linearlayout. VERTICAL);
Make a view of this linear layout
Setcontentview (LinearLayout);
(2) for normal fonts
Ordinary normal font
normal=NewTextView (this);
To set the font content, please note: currently Android mainly for Latin language can use font settings, Chinese temporarily does not support
Normal.settext ("Normal Font FYI");
Set Font size
Normal.settextsize (20.0f);
Set font to default, normal fonts
Normal.settypeface (Typeface. DEFAULT, Typeface. NORMAL);
Add the font and display it to the layout linearlayout
Linearlayout.addview (Normal,newlinearlayout.layoutparams (layoutparams. Wrap_content, Layoutparams. wrap_content));
(3) for bold font
Bold font
bold=NewTextView (this);
Bold.settext ("Bold Font FYI");
Bold.settextsize (20.0f);
Set the font color to blue
Bold.settextcolor (Color. BLUE);
Set font to default bold, bold
Bold.settypeface (Typeface. Default_bold, Typeface. BOLD);
Linearlayout.addview (Bold,newlinearlayout.layoutparams (layoutparams). Wrap_content, Layoutparams. wrap_content));
(4) for italic font
Italic font
italic=NewTextView (this);
Italic.settextsize (20f);
Italic.settext ("Italic Font FYI");
Set the font color to red
Italic.settextcolor (Color. RED);
Set font to equal width, italic typeface
Italic.settypeface (Typeface. Monospace, Typeface. ITALIC);
Linearlayout.addview (Italic,newlinearlayout.layoutparams (layoutparams. Wrap_content, Layoutparams. wrap_content));
(5) for bold italic font
Bold Italic Font
italic_bold=NewTextView (this);
Italic_bold.settextsize (20f);
Italic_bold.settext ("Italic & Bold Font FYI");
Set the font color to yellow
Italic_bold.settextcolor (Color. YELLOW);
Set font to equal width, italic typeface
Italic_bold.settypeface (Typeface. Monospace, Typeface. bold_italic);
Linearlayout.addview (Italic_bold,newlinearlayout.layoutparams (layoutparams. Wrap_content, Layoutparams. wrap_content));
(6) For Chinese imitation "bold"
Chinese font issues for Android fonts
chinese=NewTextView (this);
Chinese.settext ("Chinese bold display effect");
Set Font Color
Chinese.settextcolor (Color. MAGENTA);
Chinese.settextsize (20.0f);
Chinese.settypeface (Typeface. Default_bold, Typeface. BOLD);
The faux "bold" setting with Textpaint Setfakeboldtext to true. There is currently no support for the faux italic method
Tp=chinese.getpaint ();
Tp.setfakeboldtext (true);
Linearlayout.addview (Chinese,newlinearlayout.layoutparams (layoutparams. Wrap_content, Layoutparams. wrap_content));
(7) Custom Create font
Custom font Glyphs
custom=NewTextView (this);
//font Mgopencosmeticabold.ttf placed under assets/font/path
Typeface=typeface. Createfromasset (Getassets (), "Font/mgopencosmeticabold.ttf");
Custom.settypeface (typeface);
Custom.settext ("Custom Font FYI");
Custom.settextsize (20.0f);
Set Font Color
Custom.settextcolor (Color. CYAN);
Linearlayout.addview (custom,newlinearlayout.layoutparams (layoutparams). Wrap_content, Layoutparams. wrap_content));
Android font settings