There is small and useful library designed for this purposes:
dependencies {
compile 'com.shamanland:fonticon:0.1.9'
}
Get demo on Google Play.
You can easily add font-based icon in your layout:
<com.shamanland.fonticon.FontIconView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/ic_android"
android:textSize="@dimen/icon_size"
android:textColor="@color/icon_color"
/>
You can inflate font-icon as Drawable
from xml:
<?xml version="1.0" encoding="utf-8"?>
<font-icon
xmlns:android="http://schemas.android.com/apk/res-auto"
android:text="@string/ic_android"
android:textSize="@dimen/big_icon_size"
android:textColor="@color/green_170"
/>
Java code:
Drawable icon = FontIconDrawable.inflate(getResources(), R.xml.ic_android);
Links: