How to Use Font Awesome Icons in Android Application (2024)

In this article, I am going to show how to use the FontAwesome icons and symbols in native android application. To use font awesome icons in android application is very easy; just we place font code instead of text font. FontAwesome icons can be used using android TextView, Button View, etc. means fontawesome icons can be used like normal font and link it to fontawesome TTF file using java code.

Download and Import FontAwesome Font File

Let's take a look at an example.Download and import the FontAwesome TrueType file into your project. You can download the FontAwesome assets from GitHub.

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 infontawesome-webfont.ttf, which is located in thefonts folder.

In your Android project, navigate toapp > src > main. Themain directory should include a folder namedassets.If there isn't one, then create it. In theassetsdirectory, create another folder, fonts, and addfontawesome-webfont.ttf to this folder.

Place FontAwesome Icons Code in Strings.xml File

To place font awesome icons code in android strings.xml file, give a name like normal strings and paste font awesome cheatsheet icons code like click here.

res/values/strings.xml

<resources> <string name="app_name">FontAwesome Icons</string> <string name="font_awesome_android_ic">&#xf17b;</string> <string name="font_awesome_area_chart_ic">&#xf1fe;</string> <string name="font_awesome_cubes_ic">&#xf1b3;</string> <string name="font_awesome_mobile_phone_ic">&#xf10b;</string></resources>

Insert FontAwesome Icons in Layouts File

In android layout file, add TextViews, Buttons, etc. to place font awesome icons wherever you want. Sample XML layouts file of android application looks like this.

res/layout/activity_main.xml

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="mahesh.com.fontawesomeicons.MainActivity"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="18dp" android:text="Font Awesome Icons" android:textSize="20sp" /> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:id="@+id/font_awesome_android_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center_horizontal" android:text="@string/font_awesome_android_ic" android:textColor="#80d204" android:textSize="50sp" /> <TextView android:id="@+id/font_awesome_area_chart_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center_horizontal" android:text="@string/font_awesome_area_chart_ic" android:textColor="#0491d2" android:textSize="50sp" /> <TextView android:id="@+id/font_awesome_cubes_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center_horizontal" android:text="@string/font_awesome_cubes_ic" android:textColor="#d27c04" android:textSize="50sp" /> </LinearLayout> <TextView android:id="@+id/font_awesome_mobile_phone_icon" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="30dp" android:gravity="center_horizontal" android:text="@string/font_awesome_mobile_phone_ic" android:textColor="#02a342" android:textSize="200sp" /> <TextView android:layout_width="fill_parent" android:layout_height="fill_parent" android:autoLink="web" android:gravity="center|bottom" android:text="ViralAndroid.com" android:textSize="24sp" android:textStyle="bold" /></LinearLayout>

Your layout is ready; it’s time to work in our java activity file to make working by font awesome fonts. Open your java activity file i.e. MainActivity.java file and place little bit code in onCreate method. MainActivity.java file will looks like below.

src/MainActivity.java

package mahesh.com.fontawesomeicons;import android.graphics.Typeface;import android.os.Bundle;import android.support.v7.app.AppCompatActivity;import android.widget.TextView;public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Typeface fontAwesomeFont = Typeface.createFromAsset(getAssets(), "fontawesome-webfont.ttf"); TextView fontAwesomeAndroidIcon = (TextView) findViewById(R.id.font_awesome_android_icon); TextView fontAwesomeAreaChartIcon = (TextView) findViewById(R.id.font_awesome_area_chart_icon); TextView fontAwesomeCubesIcon = (TextView) findViewById(R.id.font_awesome_cubes_icon); TextView fontAwesomeMobilePhoneIcon = (TextView) findViewById(R.id.font_awesome_mobile_phone_icon); fontAwesomeAndroidIcon.setTypeface(fontAwesomeFont); fontAwesomeAreaChartIcon.setTypeface(fontAwesomeFont); fontAwesomeCubesIcon.setTypeface(fontAwesomeFont); fontAwesomeMobilePhoneIcon.setTypeface(fontAwesomeFont); }

You have done all things. Now, run your source code.

Conclusion

In this quick tip, I showed you how to use the FontAwesomeicon set in an Android project. FontAwesome iswidely 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.

Thank you..!!

How to Use Font Awesome Icons in Android Application (2024)
Top Articles
The impact of blockchain technology on the future of finance
How to remove encryption password for a Drive file/folder?
Dunhams Treestands
Diario Las Americas Rentas Hialeah
Edina Omni Portal
Rubratings Tampa
Walgreens Pharmqcy
Noaa Swell Forecast
Puretalkusa.com/Amac
Nikki Catsouras Head Cut In Half
Music Archives | Hotel Grand Bach - Hotel GrandBach
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Helloid Worthington Login
Ukraine-Russia war: Latest updates
Cnnfn.com Markets
Rainfall Map Oklahoma
Craigslist Malone New York
Bcbs Prefix List Phone Numbers
Procore Championship 2024 - PGA TOUR Golf Leaderboard | ESPN
111 Cubic Inch To Cc
24 Hour Drive Thru Car Wash Near Me
Walmart Car Department Phone Number
*Price Lowered! This weekend ONLY* 2006 VTX1300R, windshield & hard bags, low mi - motorcycles/scooters - by owner -...
Scream Queens Parents Guide
Employee Health Upmc
Mybiglots Net Associates
Slim Thug’s Wealth and Wellness: A Journey Beyond Music
Hdmovie2 Sbs
Cpt 90677 Reimbursem*nt 2023
Craig Woolard Net Worth
Ltg Speech Copy Paste
Water Temperature Robert Moses
Dal Tadka Recipe - Punjabi Dhaba Style
Jesus Calling Feb 13
Japanese Emoticons Stars
R3Vlimited Forum
CARLY Thank You Notes
Flashscore.com Live Football Scores Livescore
Afspraak inzien
Page 5662 – Christianity Today
Legit Ticket Sites - Seatgeek vs Stubhub [Fees, Customer Service, Security]
2700 Yen To Usd
Amc.santa Anita
Tricare Dermatologists Near Me
Bmp 202 Blue Round Pill
Crystal Glassware Ebay
Erica Mena Net Worth Forbes
Mawal Gameroom Download
Grandma's Portuguese Sweet Bread Recipe Made from Scratch
Www Extramovies Com
Www.card-Data.com/Comerica Prepaid Balance
Latest Posts
Article information

Author: Geoffrey Lueilwitz

Last Updated:

Views: 6349

Rating: 5 / 5 (60 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Geoffrey Lueilwitz

Birthday: 1997-03-23

Address: 74183 Thomas Course, Port Micheal, OK 55446-1529

Phone: +13408645881558

Job: Global Representative

Hobby: Sailing, Vehicle restoration, Rowing, Ghost hunting, Scrapbooking, Rugby, Board sports

Introduction: My name is Geoffrey Lueilwitz, I am a zealous, encouraging, sparkling, enchanting, graceful, faithful, nice person who loves writing and wants to share my knowledge and understanding with you.