Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Iconify的使用 #8

Open
NewBrandSTONE opened this issue Apr 7, 2018 · 0 comments
Open

Iconify的使用 #8

NewBrandSTONE opened this issue Apr 7, 2018 · 0 comments
Labels

Comments

@NewBrandSTONE
Copy link
Owner

NewBrandSTONE commented Apr 7, 2018

https://blog.joanzapata.com/iconify-just-got-a-lot-better/

https://github.com/JoanZapata/android-iconify

为什么会使用iconify

优点:

  1. 不需要再考虑分辨率问题了,因为矢量图不会失真。
  2. 减少app打包中图片所占用的空间。
  3. 风格统一,好看。

缺点:

  1. 制作不方便啊。
  2. 如果没有想要的图标,需要再下载一个.ttf文件。
  3. 矢量图标不够彩色图标酷炫。

关键是学习到了正确使用阿里iconfont+的姿势,下面简单说一下。

收集Icons

平时在做自己开发的APP时,没有专门的美工设计图标,所以都是从阿里iconfont+网站上搜索自己喜欢的图标,最后打包下载下来。

下载并解压

打包下载icons

解压之后的文件列表如下,

解压压缩包

使用

  1. .ttf文件存放到/assets/目录下,方便在APP中使用。
  2. 打开demo_unicode.html,获取图标的unicode
  3. 使用iconify加载自定义图标。

需要注意的是,要对demo_unicode.html中的编码做一下转换

编码转换

Java代码中不能直接使用,需要转换成\uxe769即可,直接在Java代码中引用会报错。

最终使用例子

废话不多说,我们先看使用的例子。

<IconTextView  
    android:text="Welcome {fa-smile-o} {fa-hand-peace-o} !"
    android:shadowColor="#22000000"
    android:shadowDx="0"
    android:shadowDy="5"
    android:shadowRadius="1"
    android:textSize="30sp"
    android:textColor="#2A9BDA"
    ... />

IconTextView将会用对应的图标替换{fa-smile-o}{fa-hand-peace-o}里面的内容。被替换上来的图标就跟text属性一样,有颜色、大小和阴影属性。无论图标多大,图标永远不会失真。

你可以在TextViewButton甚至是ImageViewToolBar菜单中使用图标。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant