Android Development

Methods to use superior font icons in Android

Superior Font is a very fashionable icon toolbox used on many web sites. He has each free and professional assortment of icons, however you could find many of the icons within the free assortment itself. Every icon might be represented by unicode (). We use this unicode to show the icon in TextView. Since it is a regular TextView, all textual content type attributes (shade, measurement, margins, and so on.) might be utilized.

For an instance if you wish to show Android Robotic emblem you need to use unicode as a TextView worth.

1. Superior Android Library Font

To have the ability to use the superior font icon assortment, it’s worthwhile to add the superior font information to your property straight and apply the suitable fontFace certain Viewing which is an easier job. However we wish the icons to be displayed in different widgets, as in Buttons, The menus, Decrease navigation and Navigation drawer and so on ,. The show of icon in non-textual views requires some effort. I’ve due to this fact written a library incorporating all the required strategies to make the icons in a number of widgets.

To start, embrace the fontawesome in your construct.gradle and synchronize your venture.

// nice font
Implementation data.androidhive: fontawesome: & # 39;

2. Methods to use it?

2.1 Show Icon in TextView

The best approach to show the font icon is to make use of the FontTextView textual content by setting the identify of the suitable icon as a textual content worth. This widget extends from AppCompatTextViewso that every one textual content view attributes apply to this widget.

solid_icon: To show a strong line icon, set this worth to true.
brand_icon: To show the model icon, set this worth to true.

2.2 Utilizing FontDrawable

Using the icon within the XML presentation is easy, however if you wish to use the icon for one more widget as a button or menu, you need to use the FontDrawable ingredient to use l & # 39; icon.

For instance, if you wish to use the funky font icon for the floating motion button, you need to use FontDrawable as proven beneath.

FloatingActionButton fab = findViewById (;

// use of the paper aircraft icon for FAB
FontDrawable drawable = new FontDrawable (this, R.string.fa_paper_plane_solid, true, false);

// white shade in icon
drawable.setTextColor (ContextCompat.getColor (this, android.R.shade.white));
fab.setImageDrawable (drawable);

2.three Use within the menus (decrease navigation, navigation drawer, and so on.)

It’s also possible to use font icons in widgets that use menu file to make the weather like Toolbar icons, Decrease navigation, Navigation drawer and so on., To make the icon within the menus, you need to use FontDrawable to set the icons, however this requires little hacking through java code.

The instance beneath reveals methods to make the font icons funky within the Drawer Navigation menu. You will see a whole instance right here.

Public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
Protected void onCreate (Bundle savedInstanceState)

/ **
* Altering the icons of the navigation drawer
* This entails going by way of the menu gadgets and making use of icons
* /
non-public void intDrawerLayout ()

/ **
* Loop by way of menu icons apply drawable font
* /
renderMenuIcons of personal void (menu menu, int[] icons, boolean isSolid, boolean isBrand)
for (int i = zero; i <menu.measurement (); i ++)


I hope you want this library. You probably have recommendations, please let me know within the remark part beneath.

Good coding

Hello! I’m founding father of androidhive and passionate programming. My expertise embrace Android, iOS, PHP, Ruby on Rails and way more. You probably have an concept that you desire to me to develop? Let's discuss