Example using Font Awesome icons for Android.
Included in this project is a strings.xml of all free font awesome icons on the latest version (5.10.1).
@string/fa_lightbulb
- Regular lightbulb icon
@string/fa_cat_solid
- Solid cat icon
@string/fa_google_brand
- Brand google icon
Since API level 26, Android introduced a new feature, Fonts in XML, which lets you use fonts as resources. This project shows you how to add fontawesome icons as a font file in your res directory. To use Fonts in XML on devices running Android 4.1 (API level 16) and higher, using at least Support Library 26.0 is required. Make sure to add support for appcompat-v7 to your app-level gradle.
implementation "com.android.support:appcompat-v7:28.0.0"
-
Android Developers - Fonts in XML
-
Font Awesome - Website
-
Font Awesome Github - Repo
Referencing Font Icons within a TextView
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/fa_regular"
android:text="@string/fa_lightbulb"
android:textColor="@color/colorPrimary" />