Tuesday, January 16, 2018

Want to use Font Awesome in Android?



It's actually pretty easy - ignore the Stackoverflow posts since they are from Studio 1.x:

1) Add the TTF to the font directory
2) Rename and lose the dashes so it will build
3) Add a fontawesome.xml font resource file with (right click)->New from the font directory:


<?xml version="1.0" encoding="utf-8"?><font-family xmlns:android="http://schemas.android.com/apk/res/android">    <font        android:fontStyle="normal"        android:fontWeight="400"        android:font="@font/fontawesomewebfont" /></font-family>


4) Now add my gist that maps the Unicode to Java-safe strings:

https://gist.github.com/lpreimesberger/043f529734389b385b65f11394dc8d60

5) Boom - switch the fonts to Font Awesome for what you want to iconize and use the fa_* strings and you'll have pretty icons that scale:




No comments:

Post a Comment