SimpalmGourav SimpalmGourav - 10 months ago 46
Android Question

Font- Awesome are not working in android app

I am using a custom font named AwesomeFont in Android App. This help us to produce scalable vector icon. Now the font file get applied on the view (both TextView and EditText) if the application launches from beginning but if the application is in background and get open after few minutes the font-file from the views get removed.

I also try to set typeface from onResume() method but it doesn't help me to get rid of the problem.

Please suggest a solution.

I found that that this problem exist for every custom font that I am using in the application. Custom font get applied throughout the application if is starts from launcher-icon(splash screen), but not if app launches from background after few minutes.

Answer Source

1- Copy fontawesome-webfont.ttf into my assests folder

2-Create an entry in strings.xml for each icon. Eg for a fa-bell:

 <string name="bell">&#xf0f3;</string>

3-create entry in the view of my xml layout:

 android:text="@string/bell" />

4-Loaded the font in my onCreate method and set it for the appropriate Views:

   Typeface font = Typeface.createFromAsset( getAssets(), "fontawesome-webfont.ttf" );

    Button button = (Button)findViewById(;

For more See this