600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > android 字体图标制作 Android_矢量字体图标制作并使用

android 字体图标制作 Android_矢量字体图标制作并使用

时间:2020-11-28 15:21:18

相关推荐

android 字体图标制作 Android_矢量字体图标制作并使用

本文目标

利用阿里iconfont制作矢量文字图标

1、搜索需要的图标,比如我要搜索一个首页,如下图:

2.添加到购物车并打开,如下图

3.Add To Project,创建一个项目,下图中创建了演示的项目,然后点击confirm

4.点击Download code

5.下载完成解压

6.打开demo_index.html预览一下

收藏图标下面的这一串Unicode码就是图标

7.在安卓中使用

必须要写在strings中,然后在使用

8.两个自定义view

internal class IconFontButton @JvmOverloads constructor(

context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0

) : AppCompatButton(context, attrs, defStyleAttr) {

init {

val typeface = Typeface.createFromAsset(context.assets, "fonts/iconfont.ttf");

setTypeface(typeface)

}

}

class IconFontTextView

@JvmOverloads constructor(context: Context, attributeSet: AttributeSet?, defStyle: Int = 0) :

AppCompatTextView(context, attributeSet, defStyle) {

init {

val typeface = Typeface.createFromAsset(

context.assets,

"fonts/iconfont.ttf"

);

setTypeface(typeface)

}

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。