Font Icons

Introduction:

Font icon is mainly used to reduce .apk size and do not take much more memory for the image file, before we have used many images in your projects its may occur out of memory issue and project size also too high.

FontAwesome is an awesome tool for designers and developers which give us scalable vector icons that can be easily customized. You can style a FontAwesome icon as any other fonts such as size, color, shadow, animation, transition etc. FontAwesome offers more than 605 fonts icons in a single collection. You don't need JavaScript to run font awesome and it has infinite scalability which means every icon looks great and awesome at any size you define. Font awesome is free for commercial use and is also desktop friendly.



There are 4 files for each icon: mdpi, hdpi, xhdpi, xxhdpi. Total size of those 20 files is 33,8 kb (33824 b).


Approximately 6-8 kb for the one icon. But in some cases (when your icons have quite much details) they can take around 10 kb per one icon.


So, what about font size? Well, size of .ttf file which contains these icons takes 2,3 kb (2280 b). This is just 6% from .png files size! There is 30 kb saved only for 5 icons!
 
Steps:

MainActivity

1. Download fontawesome-webfont.ttf file from this link.

2. Copied and pasted fontawesome-webfont.ttf into assests folder.  

3. Created an entry in strings.xml for each icon.
<string name="icon_heart">&#xf004;</string>
<string name="icon_bitbucket">&#xf171;</string>
<string name="icon_birthday">&#xf1fd;</string>
<string name="icon_vimeo">&#xf194;</string>
4. View of my xml layout:

<TextView
    android:id="@+id/textView_one"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:layout_alignParentTop="true"
    android:layout_marginTop="50dp"
    android:textColor="@color/colorAccent"
    android:textSize="50dp"
    android:text="@string/icon_heart" />

4. Loaded the font in my onCreate method and set it for the appropriate Views:
Typeface font = Typeface.createFromAsset( getAssets(), "fontawesome-webfont.ttf");

textViewOne = (TextView)findViewById( R.id.textView_one);
textViewTwo = (TextView)findViewById( R.id.textView_two);
textViewThree = (TextView)findViewById( R.id.textView_three);
textViewFour = (TextView)findViewById( R.id.textView_four);
textViewOne.setTypeface(font);
textViewTwo.setTypeface(font);
textViewThree.setTypeface(font);
textViewFour.setTypeface(font);
5. For more icons needed get it from this link.


Happy Coding....

Previous
Next Post »

14 comments

Write comments
Unknown
AUTHOR
October 10, 2018 at 3:11 PM delete

After seeing your article I want to say that the presentation is very good and also a well-written article with some very good information which is very useful for the readers....thanks for sharing it and do share more posts like this.
Data Science Training in Chennai | Data Science course in anna nagar
Data Science course in chennai | Data science course in Bangalore
Data Science course in marathahalli | Data Science course in btm

Reply
avatar
Mounika
AUTHOR
October 10, 2018 at 3:25 PM delete

This is my 1st visit to your web... But I'm so impressed with your content. Good Job!
python training in velachery | python training institute in chennai

Reply
avatar
shethal
AUTHOR
October 12, 2018 at 12:22 PM delete

You’ve written a really great article here. Your writing style makes this material easy to understand.. I agree with some of the many points you have made. Thank you for this is real thought-provoking content

advanced excel training in bangalore

Reply
avatar
Janardhan
AUTHOR
March 16, 2020 at 5:31 PM delete

Usually I never comment on blogs but your article is so convincing that I never stop myself to say something about it. You’re doing a great job,Keep it up.

Try Our Vashikaran Expert In Toronto Services and Get All the benefits of it in your life, we make All your Personal problems solved in just minutes.

Reply
avatar
Madhuvarsha
AUTHOR
May 11, 2020 at 4:58 PM delete

I wanted to thank you for this great read!! I definitely enjoying every little bit of it I have you bookmarked to check out new stuff you post.is article. Thanks for sharing nice article about JAVA.
Java training in chennai | Java training in annanagar | Java training in omr | Java training in porur | Java training in tambaram | Java training in velachery

Reply
avatar
Anonymous
AUTHOR
May 31, 2020 at 4:04 PM delete

The site was so nice, I found out about a lot of great things. I like the way you make your blog posts. Keep up the good work and may you gain success in the long run.

Big Data Hadoop Training In Chennai | Big Data Hadoop Training In anna nagar | Big Data Hadoop Training In omr | Big Data Hadoop Training In porur | Big Data Hadoop Training In tambaram | Big Data Hadoop Training In velachery

Reply
avatar
Rashika
AUTHOR
June 17, 2020 at 7:53 PM delete

Nice tips. Very innovative... Your post shows all your effort and great experience towards your work Your Information is Great if mastered very well.
AWS training in chennai | AWS training in annanagar | AWS training in omr | AWS training in porur | AWS training in tambaram | AWS training in velachery

Reply
avatar
lavanya
AUTHOR
July 23, 2020 at 12:29 AM delete

I found your blog while searching for the updates, I am happy to be here. Very useful content and also easily understandable providing.. Believe me I did wrote an post about tutorials for beginners with reference of your blog. Best of luck
Java training in Chennai

Java training in Bangalore

Java training in Hyderabad

Java Training in Coimbatore

Java Online Training

Reply
avatar
karthik.boon
AUTHOR
January 15, 2021 at 1:44 AM delete

Great Article android based projects

Java Training in Chennai Project Center in Chennai Java Training in Chennai projects for cse The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training Project Centers in Chennai

Reply
avatar