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

本文介绍如何从IconFont网站选择并应用图标至Android项目。具体步骤包括:选择图标、下载图标包、将图标文件放置到项目的assets文件夹,并通过TextView设置图标。

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" />

 

转载于:https://www.cnblogs.com/WTFFFFFF/p/9007402.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值