Objective:
A design manual in Android designs. There are commonly used UI icons, icon size specifications, and so on in the design manual.
Among them, there is a TTF font, previously felt useless. But when I was studying, I often saw a lot of developers using Google
The TTF font provided. I counted it. There are 19 fonts to choose from, while Android comes with only 4 options to choose from. I use
A project to test all the font effects.
:
Java code:
ImportAndroid.os.Bundle;Importandroid.app.Activity;ImportAndroid.graphics.Typeface;ImportAndroid.widget.TextView; Public classMainactivityextendsActivity {Private intTtf_str[] ={r.string.ttf_1, r.string.ttf_2, R.string.ttf_3, R.string.ttf_4, R.string.ttf_5, R.string.ttf_6, R.string . ttf_7, R.string.ttf_8, R.string.ttf_9, R.string.ttf_10, R.string.ttf_11, R.string.ttf_12, R.string. Ttf_13, R.string.ttf_14, R.string.ttf_15, R.string.ttf_16, R.string.ttf_17, r.string.ttf_18, R.string.ttf_19,} ; Private intTtf_id[] ={r.id.ttf_1, r.id.ttf_2, R.id.ttf_3, R.id.ttf_4, R.id.ttf_5, R.id.ttf_6, r.id.ttf_7, R.id.ttf_8, R.id.ttf _9, R.id.ttf_10, R.id.ttf_11, R.id.ttf_12, r.id.ttf_13, r.id.ttf_14, R.id.ttf_15, R.id.ttf_16, R.id. Ttf_17, R.id.ttf_18, r.id.ttf_19,}; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Setcontentview (R.layout.activity_main); /** Set Custom Auto*/ for(inti = 0; I <= 18; ++i) Showttf ("fonts/" +getString (Ttf_str[i]), ttf_id[i]); } Private voidShowttf (String Path,intID) {Typeface fontface=Typeface.createfromasset (getassets (), path); TextView text=(TextView) Findviewbyid (ID); Text.settypeface (Fontface); }}
Note: Android Project package download. All TTF fonts are included in the project. Point here
Android Custom TTF Font