代码之家  ›  专栏  ›  技术社区  ›  Mayur Dabhi

如何在android中使用文本编写此类图标

  •  1
  • Mayur Dabhi  · 技术社区  · 6 年前

    Image

    1 回复  |  直到 6 年前
        1
  •  1
  •   Aseem Sharma    6 年前

    Font Awesome可以用于您的需求,您也可以在不使用WebView的情况下实现它。 为此,您需要创建一个自定义 IconTextView

        public class IconTextView extends TextView {
    
        private Context context;
    
        public IconTextView(Context context) {
            super(context);
            this.context = context;
            createView();
        }
    
        public IconTextView(Context context, AttributeSet attrs) {
            super(context, attrs);
            this.context = context;
            createView();
        }
    
      private void createView(){
       setGravity(Gravity.CENTER);
       setTypeface(FontTypeface.get("FontAwesome.otf", context));
      }
    }
    

    你需要 download 很棒的字体和add.otf文件,并将其保存在 assets src中的文件夹->主要的

    article .