Giter VIP home page Giter VIP logo

fonttest's Introduction

用 TextView 来显示图片

通过给 TextView 设置图标字体库来显示图片,以到达适配图片和优化App的效果。

效果图如下:

图中的图标全都是 TextView

仓库文件说明

  • FontTest 是项目的 Demo 源码
  • FontAwesome 文件夹内包含两个与 FontAwesome 字体库相关的文件
    1. fontawesome-webfont.ttf 是字体库文件。
    2. string.xmlfont-awsome-for-android 文件,即 FontAwesome 在 Android 开发使用中,图标和字符的对照资源文件。

Demo 源码说明

在 FontTest 是一个通过字体库使 TextView 来显示图片的实例,其中提供了四种不同的设置字体的方法:

  1. 手动动态方式。(普通方法)
  2. 通过创建一个递归遍历给所有 TextView 设置字体的 FontHelper 工具类的方式。(适用与全局 TextView 都需要设置字体)
  3. 通过 LayoutInflateFactory 的方式。(适用与全局 TextView 都需要设置字体,高效)
  4. 自定义 View 的方式。(使用灵活,逻辑简单)

项目详细介绍 & 生成自己的字体库

本项目详细的原理介绍和如何生成自己的字体库的详细教程点击下面博客地址:
http://ocnyang.com/2016/12/06/IconFont/

http://www.jianshu.com/p/e95890e56bc2




附录及感谢:
Font-Awesome 字体库
font-awsome-for-android 图标字符对照表
Font Awsome Cheatsheet 官方提供的 图标字符对照表

fonttest's People

Contributors

ocnyang avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.