In Android, our applications can flexibly embed their own font files to enable normal display of personalized text on various mobile phones. We all know that the settypeface method of textview can set the display characteristics of the target text, such as font, color, bold, and italic. We can directly find a truetypefont font file named. TTF. for Win32 users, you can find a lot in the Windows/fonts folder. For example, is good, but the size is too large. Because the android assets class has a size limit of 1 MB for a single file, we should first find an English font for testing. Here we place the font file android123.ttf In the fonts directory of the assets folder of the project.
Typeface TF = typeface. createfromasset (getassets (), "fonts/android123.ttf ");
Textview TV = (textview) findviewbyid (R. Id. Text );
TV. settypeface (TF); // sets the textview style.
TV. settext ("cwj test ");
TV. settextsize (12 );
TV. settextcolor (color. Red );