Font-awesome is an icon collection font designed for bootstrap, which contains more than 300 commonly used icons. Using Font-awesome also has the following advantages:
1, reduce the drawing of the icon work
2, suitable for flat design of the interface
3, the size of the icon and the color can be set in the code itself, the bukkake is not fixed, can be large variability
4, reduce the size of the APK
How to use Font-awesome:
To http://fortawesome.github.io/Font-Awesome/download Font-awesome fonts, Currently the latest version is 4.3.0 then unzip the package and place the Fontawesome-webfont.ttf file under the Fonts folder under the assets directory of the project. To http://fortawesome.github.io/Font-Awesome/cheatsheet/view the corresponding icon, you can download the page to save it. You can also find in the Font-awesome.css file in the CSS directory of the downloaded Font-awesome font, I have tried, I really do not see which icon, so still in the http://fortawesome.github.io/ Font-awesome/cheatsheet better.
Then define your icon in the strings file under the values folder, such as my heart icon so defined in Strings.xml: <string name= "heard" >& #xf004; </string >. The TextView is then defined in the layout file, such as:
<textview
Android:id= "@+id/test_view"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
android:text= "@string/heard"//Note this must not be forgotten
Android:textsize= "50SP"
Android:textcolor= "#F59012"
Android:textappearance= "? Android:attr/textappearancelarge"/>
Then in Java code, you define TextView in your activity.
Public classLoginactivityextendsActivityImplementsonclicklistener{PrivateTextView T1;@Overrideprotected voidonCreate (Bundle savedinstancestate) {//TODO auto-generated Method Stub Super. OnCreate (savedinstancestate); Setcontentview (R.layout.login); Typeface Font= Typeface.createfromasset (Getassets (), "Fontawesome-webfont.ttf");//Remember to add this sentence T1=(TextView) Findviewbyid (R.id.test_view);t1.settypeface (font);
Typeface font = Typeface.createfromasset (Getassets (), "Fontawesome-webfont.ttf");
Settypeface (font); this cannot be forgotten. Then run your project and you'll see the icon you want in the TextView.
As simple as this, the individual feels much better than what they are designed to do, and the flat style fits the style of the interface design.
If you need help please leave a message, Welcome to discuss!
Android flat screen design-use Font-awesome in Android