Enhancing Android Performance Using Icon Fonts
suggest changeRemarks
Icon fonts are font files whose characters are symbols. An application can draw them like any other glyph.
They are:
- Flexible
- Scalable
- Vectors
- Fast Processable
- Light Weight
- Accessible
Effect on Size
Exporting an image in various sizes for android devices would cost your app, additional asset size of around 30kB per image. While adding a font file(.ttf) with around 36 icons would cost just 9kB. Just imagine the case if you are adding 36 individual files of various configurations it would be around 1000kB. It’s a reasonable amount of space that you will save by using icon fonts.
Limitations of Icon fonts.
- A navigation drawer's menu icon is a drawable resource. A menu XML file cannot point a menu icon at a font glyph. Use a vector drawable for those icons, or build the icon in code.
- A floating action button has no
setText()method, so a font glyph is not a direct replacement for its icon. - A font stored in
assetsis applied in Java, or by a custom view, as described in this post. From API 26, a font file inres/fontcan be selected withandroid:fontFamily.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents