How to use Font Awesome icon in android application?

后端 未结 9 2095
时光说笑
时光说笑 2020-12-02 20:58

I want to use Font Awesome\'s icon set in my android application. I have some TextView to set those icons. I don\'t want to use any png image. My Textview is li

9条回答
  •  眼角桃花
    2020-12-02 21:35

    You can also import the raw vector images from Font Awesome and import them as drawables in your project with the help of creating a new Vector Asset in Android Studio:

    Go to the folder where you have installed Font Awesome

    ...../fontawesome-pro-version#/advanced-options/raw-svg

    There you will find 4 folders: brands, light, regular and solid.

    All the icons are available as separated vector images in those 4 folders

    To import an icon, go to resources, right click and select New -> Vector asset. A dialog will open. Select Local file as option, and select the vector image you want to import (path). Name of the image will be substracted from the image file.

    And then you can resolve your problem by simple using a compound TextView, something like this:

     
    

    One advantage of this solution is, that you only need to import the icons you really need, without the overhead of a complete or even more fonts, as the icons are divided over 4 fonts.

提交回复
热议问题