Nimblechapps Blog

This is the section where we get a chance to rant about latest happenings in the tech world. Keen to know our thoughts? Refer our blogs

How To Use the Font Awesome Icon Pack in an Android

Font Awesome_Android_2

In this tutorial, I will show you how to use the Font Awesome icon pack in an Android project. Font Awesome is a great timesaver for several reasons.

First, you don’t have to worry about different screen densities on different smartphones. If you want to use PNG files, you have to include in your package at least four different versions of every icon. Not only that, on some ultra-dense HD displays, your icons might look grainy. This is something you certainly want to avoid. With Font Awesome, however, you just have to include a single TTF file.


Steps to use Font Awesome in Android

1) Create a new project


2) Create String resources in res/values/string.xml

[pastacode lang=”java” manual=”%3Cresources%3E%E2%80%A8%0A%3Cstring%20name%3D%22app_name%22%3EAwesomeFont%3C%2Fstring%3E%E2%80%A8%0A%3Cstring%20name%3D%22fa_icon_areachart%22%3E%3Cspan%3E%26%3C%2Fspan%3E%23xf1fe%3B%3C%2Fstring%3E%0A%3Cstring%20name%3D%22fa_icon_piechart%22%3E%26%23xf200%3B%3C%2Fstring%3E%E2%80%A8%0A%3Cstring%20name%3D%22fa_icon_linechart%22%3E%26%23xf201%3B%3C%2Fstring%3E%E2%80%A8%0A%3C%2Fresources%3E” message=”” highlight=”” provider=”manual”/]

3) Now Create layout like below in activity_main.xml like this

[pastacode lang=”java” manual=”” message=”” highlight=”” provider=”manual”/]


How to Import Font Awesome in Android

You need Download and import the FontAwesome TrueType file into your project. You can download the FontAwesome assets from here —

When you download FontAwesome, you end up with an archive that includes a number of files and folders. Most of these are useful for web projects. We are only interested in fontawesome-webfont.ttf, which is located in the fonts folder.

1) Create assets folder and subdirectory fonts and add fontawesome-webfont.ttf to this folder


In your Android project, navigate to app > src > main. The main directory should include a folder named assets. If there isn’t one, then create it. In the assets directory, create another folder, fonts, and add fontawesome-webfont.ttf to this folder.

2) Create a helper class

Now that you’ve successfully included the FontAwesome font file in your Android project, it’s time to use it. We will be creating a helper class to make this easier. The class we are going to use is The Typeface class specifies the typeface and intrinsic style of a font. This is used to specify how text appears when drawn (and measured).

Let’s start by creating the helper class. Create a new Java class and name it FontManager:

[pastacode lang=”java” manual=”public%20class%20FontManager%20%7B%0A%20%20%20%20public%20static%20final%20String%20ROOT%20%3D%20%22fonts%2F%22%2C%0A%20%20%20%20FONTAWESOME%20%3D%20ROOT%20%2B%20%22fontawesome-webfont.ttf%22%3B%20%20%20%0A%20%20%20%20public%20static%20Typeface%20getTypeface(Context%20context%2C%20String%20font)%20%7B%0A%20%20%20%20%20%20%20%20return%20Typeface.createFromAsset(context.getAssets()%2C%20font)%3B%0A%20%20%20%20%7D%20%20%20%20%0A%7D” message=”” highlight=”” provider=”manual”/]

3) Now use font awesome to your textview using below code

[pastacode lang=”markup” manual=”Typeface%20iconFont%20%3D%20FontManager.getTypeface(getApplicationContext()%2C%20FontManager.FONTAWESOME)%3B%0AtvIcon1%20%3D%20(TextView)%20findViewById(” message=”” highlight=”” provider=”manual”/]



In this quick tip, I showed you how to use the FontAwesome icon set in an Android project. FontAwesome is widely known, very rich, and free. The result is sharp and crisp icons, even on high resolution displays. As an added bonus, changing an icon’s size or color is as simple as changing an XML attribute.

You can check this topic in iOS : Font Awesome for iOS

You can find the complete code here: