Leverage the font awesome icon library (http://fortawesome.github.io/Font-Awesome/) in your android projects. The vector images will remain crisp and clear on all device sizes
Based on "Font Awesome by Dave Gandy - http://fontawesome.io".
- Add the fontawesome-webfont.ttf file into your assets directory
- Add the font_awesome.xml file to your res folder
- Add the two classes ButtonAwesome.java and TextAwesome.java to your package path
There are two ways to use the icons
-
XML layouts, just include the extended textview or button in your layout, set the text to the string resource icon
<com.FontAwesome.Example.TextAwesome android:id="@+id/tvThumb" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/icon_thumbs_up" android:textSize="30sp" /> <com.FontAwesome.Example.ButtonAwesome android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/icon_check_sign" >
-
Create a view programmatically
TextAwesome tvFacebook = new TextAwesome(this); tvFacebook.setText(this.getResources().getString(R.string.icon_facebook_sign)); tvFacebook.setTextSize(TypedValue.COMPLEX_UNIT_SP,50); layoutMain.addView(tvFacebook, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
See the example project for more details