How To Use Font Awesome in Android Studio

Android studio by default gives very fewer fonts/icons which you can access through creating Image Assets or Vector Assets. so here I am going to tell you how to add ‘font awesome’ in your android studio project.

You can place Font Awesome icons just about anywhere using a style prefix and the icon’s name. They have created icons which will take on the characteristics and appear alongside text naturally.

To Know what are font awesome check my previous post with more tools to get help while designing an application here.

so let’s begin

*please keep the folders name same as I did.

you can also go to app> new > module > Assets to add assets folder to your android studio. Then you can paste the .ttf file to the asset folder.

Create A new Android Studio Project > MyFontAwesomeExample.

Create A new Folder Anywhere on your pc named assets> make a new folder in assets > fonts> in fonts paste the font awesome ttf file. Download font awesome.ttf.

Now go to project drop down and go to the main folder and paste assets folder in it.

create a new java class MyTextViewFontAwesome.java



now go to values resource file and create new resource file called icon.xml

Go to Values folder and create a new Icon File (Select type of file icon). Now Write in resource tag:

now go to layout resource file

Tips:

  1.  is the format of using font awesome. You just need to change the four character+digit to change your icon.
  2. Create an icon file in your values folder to add font awesome shortcodes.
  3. use naming convention correctly. Name the icon where you are going to use it like as a password icon. user icon, lock icon, logo etc.
  4. To use font awesome always use  <com.i.fontawesome.MyTextViewFontAwesome/> this will not work with simple<textview/> tag.
  5. Font Awesome is not By Default clickable so mention clickable=true if you want to add click listeners to font awesome icon.
  6. There are some icons which are only available to Premium User/Paid users. If you are using a free account you can not access those free icons even if you get the four digit_character code.

How useful was this post?

Do not forget to rate! this helps us to Improve.

Average rating / 5. Vote count:

Read More Like This..

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

Safiya Akhtar

Safiya Akhtar is Android Application Developer in India. She is currently working as a public consultant for career and education too, besides blogging and freelancing. She believes that it is never too late or too early to start what you have always dreamed of.

3 thoughts on “How To Use Font Awesome in Android Studio

Your Views And Question are Welcome Here!