String resources for the free FontAwesome icons for use with AndroidStudio.
-
First create your Font Resource Directory
- Right-click the res folder and go to New > Android resource directory
- In the Resource type list, select font, and then click OK
- Check this guide for more details
-
Download the FontAwesome TTF files
- Brands Icons: fa-brands-400.ttf
- Regular Icons: fa-regular-400.ttf
- Solid Icons fa-brands-900.ttf
-
Add your font files in the font folder
- Right-click the font folder and go to Show in Explorer
- Move your desired TTF files to this folder
-
Create your icon dictionary:
- Right-click the values resources folder and go to Show in Explorer
- Move the XML Files to this folder:
- XML for Brands Icons:
strings_fa_brands.xml
- XML for Regular Icons:
strings_fa_regular.xml
- XML for Solid Icons:
strings_fa_solid.xml
- XML for Brands Icons:
- Or check the FontAwesome Cheatsheet to create your own, the XML will look like this:
<resources> <string name="fa_regular_sun"></string> <string name="fa_regular_surprise"></string> <string name="fa_regular_thumbs_up"></string> </resources>
-
In the layout XML file, set the
text
andfontFamily
attribute to the icon you want<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/fa_regular_thumbs_up" android:fontFamily="@font/fa-regular-400"/>