Ali choobdar
Ali choobdar

Reputation: 121

Is it a bad practice to use font icons in native android apps?

I am going to use font icons instead of pngs in my native android app. I cant find any recommendation to use or not to use font icons.

So is it a bad practice or a good one to use font icons in native android apps?

(By native i mean i don't use webview for user interface)

Upvotes: 4

Views: 981

Answers (1)

Konstantin Loginov
Konstantin Loginov

Reputation: 16010

As any other practice in the world, it has its own pros and cons.

Pros:

  • changing colour of the icon becomes super-easy fix
  • since font icons are SVGs, they scale without visual artefacts (comparing to scaling small .png)
  • icon-font takes less space, than same number of icons stored as .png's

Cons:

  • It's pretty inflexible, unless you can edit font and add new elements by yourself.
  • It's not readable:

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="\uE118"/>
    

    \uE118 and other unicodes are barely something you can keep in memory

  • You're forced to use custom typefaces everywhere you use icons, which leads to spaghetti code:

    • all TextViews should have ids
    • you set Typefaces everywhere in the code-behind

      (or, as I did, extend TextView class and setting Typeface based on the custom string attribute(with font path) you're passing in the xml)

  • You'd be surprise, how often people, who generate the fonts for you, change icons' codes. As a result, you can get pretty bizarre effects

My personal observation:
png's are better for prototyping, for building up something fast; icon-fonts are better, once you develop production-quality, stable from design perspective application.

Upvotes: 6

Related Questions