码迷,mamicode.com
首页 > 移动开发 > 详细

【Android】使用IconFont显示图片,从而缩小体积

时间:2018-05-08 14:21:05      阅读:188      评论:0      收藏:0      [点我收藏+]

标签:type   ttext   test   amp   div   class   com   round   bsp   

1、从http://www.iconfont.cn/选取需要添加的图标,添加到购物车。
2、在购物车中选择下载代码。

技术分享图片
3、打开压缩包,将压缩包中的四个文件放入工程中的asstes文件夹下。

技术分享图片
4、在代码中通过设置TextView的TypeFace导入图片。

1 TextView testView = findViewById(R.id.text);
2 Typeface typeface = Typeface.createFromAsset(getAssets(), "iconfont.ttf");
3 testView.setTypeface(typeface);
4 testView.setText(Html.fromHtml("󰍃"));
<TextView
    android:id="@+id/text"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"
    android:gravity="center"
    android:textColor="#ffcc0000"
    android:textSize="30sp" />

 

【Android】使用IconFont显示图片,从而缩小体积

标签:type   ttext   test   amp   div   class   com   round   bsp   

原文地址:https://www.cnblogs.com/WTFFFFFF/p/9007402.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!