I'm trying to use Font Awesome on my application, I was able to integrate the font using Typeface.createFromAsset()
, but I also want to use the icons provided by this font, but so far I haven't been able to do that.
This particular font contains icons inside the Unicode Private Use Area (PUA), for things like media player controls, file system access, arrows, etc.
Has anybody used fonts that contain icons and symbols on Android, is this possible at all?
Font Awesome seems to be working fine for me in my android app. I did the following:
fontawesome-webfont.ttf
into my assests folderCreated an entry in strings.xml for each icon. Eg for a heart:
<string name="icon_heart"></string>
Referenced said entry in the view of my xml layout:
<Button
android:id="@+id/like"
style="?android:attr/buttonStyleSmall"
...
android:text="@string/icon_heart" />
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.like );
button.setTypeface(font);