【Android】使用IconFont顯示圖片,從而縮小體積
阿新 • • 發佈:2018-05-08
center png 分享 壓縮 you 通過 顯示 white 下載
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顯示圖片,從而縮小體積