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:
[Java] view plaincopy
Assetmanager mgr=getassets (); //Get Assetmanager
Typeface Tf=typeface.createfromasset (Mgr, "Fonts/ttf.ttf"); //According to the path to get typeface
Tv=findviewbyid (R.id.textview);
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:
[Java] view plaincopy
TextView TV = (TextView) Findviewbyid (R.ID.TEXTVIEW01);
Tv.getpaint (). Setfakeboldtext (true); //Chinese Imitation "bold"--use Textpaint's faux "bold" setting Setfakeboldtext to True.
Note: Some fonts in Chinese are not valid, although they will not be error, but not Chinese. Second, the use of Roboto
The default font has been used Roboto since Android4.0, and here's how to use it:
[Java] view plaincopy
-
android:fontfamily= "Sans-serif"   span class= "comment" style= "Margin:0px;padding:0px;border:none;color:rgb (0,130,0); background-color:inherit;" >// roboto regular
-
android: Fontfamily= "Sans-serif-light" roboto light
-
android: Fontfamily= "Sans-serif-condensed" roboto condensed   
android:fontfamily="Sans-serif-thin" //Roboto thin (Android 4.2)
//in combination with
android: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
Other great article articles
Android KSOAP2 call. NET Webservicejquery Tutorial (8)- Using the reverse Insert method for DOM tree operation Android Learning Note (34) using Alertdialog to create a simple dialog box Android learning Note (33) Gallery View (Gallery) features and usage Android navidgation drawer How to change the list selection in the navigation drawer ...
More about Android development articles
This article is from the "Moe It People" blog, please be sure to keep this source http://jlins.blog.51cto.com/4487484/1599257
Android font settings, Roboto font use