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.
1- Copy fontawesome-webfont.ttf into my assests folder
2-Create an entry in strings.xml for each icon. Eg for a fa-bell:
3-create entry in the view of my xml layout:
<Button android:id="@+id/bells" style="?android:attr/buttonStyleSmall" ... 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( R.id.bells); button.setTypeface(font);
For more See this