FontawesomeLib is a library that makes it easy to use Fontawesome on Android.
It is based on Fontawesome 5
- Easily get the typeface and text of fontawesome by name of cheatsheet.
- Easily apply icons to Button, TextView.
Fontawesome | This library |
---|---|
5.13.0 | 1.0.2 |
5.10.1 | 1.0.1 |
5.8.1 | 1.0.0 |
5.8.1 | 0.0.1 |
SampleApp | Icon List | Draw to Button, ImageView |
---|---|---|
// Initialize
FontawesomeLib.getInstance().init(getAssets(), "fonts/fa-solid-900.ttf", "fonts/fa-regular-400.ttf", "fonts/fa-brands-400.ttf");
// To get fontawesome icon text
String text = FontawesomeLib.getInstance().getText(FontawesomeLib.FontType.TYPE_SOLID, "adjust");
// -> text is 0xf042
// To get typeface
Typeface tf = FontawesomeLib.getInstance().getTypeface(FontawesomeLib.FontType.TYPE_SOLID);
// To apply the fontawesome icon to a TextView or Button
FontawesomeLib.getInstance().setIcon(FontawesomeLib.FontType.TYPE_SOLID, "adjust", buttonTest);
FontawesomeLib.getInstance().setIcon(FontawesomeLib.FontType.TYPE_SOLID, "atlas", textViewTest);
// Initialize
FontawesomeLib.getInstance().init(assets, "fonts/fa-solid-900.ttf", "fonts/fa-regular-400.ttf", "fonts/fa-brands-400.ttf")
// To get fontawesome icon text
val text = FontawesomeLib.getInstance().getText(FontawesomeLib.FontType.TYPE_SOLID, "adjust")
// -> text is 0xf042
// To get typeface
val tf = FontawesomeLib.getInstance().getTypeface(FontawesomeLib.FontType.TYPE_SOLID)
// To apply the fontawesome icon to a TextView or Button
FontawesomeLib.getInstance().setIcon(FontawesomeLib.FontType.TYPE_SOLID, "adjust", buttonTest)
FontawesomeLib.getInstance().setIcon(FontawesomeLib.FontType.TYPE_SOLID, "atlas", textViewTest)
- Go to fontawesome and download "Free for Web".
- Copy webfonts/*.ttf to Android Project's /src/main/assets/fonts folder.
- Add to build.gradle.
implementation 'com.yypbd.fontawesomelib:fontawesomelib:1.x.x'
- View the sample app or code example.
MIT License.