2

In my app there are a lot of places where i have to programmatically add icons into my textviews.

On the Android material design website i saw, that you can use icon fonts, but there is nothing that indicates that you can do this inside an android app, lose from the png and svg icons itself.

http://google.github.io/material-design-icons/

is it possible to use icon-fonts in android? and if it is possible how do i implemented this into my app? can someone help me with this?.

quantum apps
  • 938
  • 2
  • 13
  • 25

3 Answers3

3

With the latest version of the Android Studio, you can now generate the Material icon by

  1. In Android Studio, open an Android app project.
  2. In the Project window, select the Android view.
  3. Right-click the res folder and select New > Vector Asset.

Vector images can also be generated by selecting vector image option

More information about vector assets can be found here https://developer.android.com/studio/write/vector-asset-studio

Njeru Cyrus
  • 1,753
  • 21
  • 22
1

You could have a look at the Android-Ionics library: https://github.com/mikepenz/Android-Iconics

It has many built-in fonts including the Material Design Icon Font and can be used for ImageViews, TextViews and Buttons.

Apart from that you can use the Material Design Icon Font like any other font:

  • Download .ttf file and save it under main/assets/fonts
  • Define strings for the unicode values you need, e.g. something like

    <string name="myicon">&#58671;</string>
    
  • Load typeface in your application and set typeface for textview

  • Use string myicon as text in your textview
anti_gone
  • 973
  • 8
  • 18
0

Unfortunately I can't find built-in solution for this, but you can check this samples with external libs

http://blog.shamanland.com/2013/11/how-to-use-icon-fonts-in-android.html http://fortawesome.github.io/Font-Awesome/icon/android/ http://code.tutsplus.com/tutorials/how-to-use-fontawesome-in-an-android-app--cms-24167

Vika L.
  • 265
  • 1
  • 11