<Android特效>Fontinator

时间:2015-09-03 02:14:18   收藏:0   阅读:380

Fontinator

介绍:

介绍:

Fontinator是一个让使用自定义字体更方便的安卓库。

运行效果:

?

使用说明:

1. 把字体添加到/assets/fonts 目录

2. 把此项目导入为Module

3. 在Application Gradle文件中添加compile project(‘:fontinator‘)?

?

添加?xmlns:app到xml布局的根节点

?xmlns:app="http://schemas.android.com/apk/res-auto"

?

工作原理

Fontinator继承了基于TextView的安卓控件,比如Button,注入一个Cached Fontface loader。

问题

安卓的布局编辑器无法预览自定义字体。

根据基于TextView的控件制作一个自定义控件

选择 1: 就是继承

选择 2:使用TypefaceLoader和Typefaceable接口

?

import?de.morrox.fontinator.utilities.TypefaceLoader;

import?de.morrox.fontinator.utilities.Typefaceable;

?

public?class?MyCustomFontButton?extends?Button?implements?Typefaceable{

????private?TypefaceLoader?typefaceLoader;

????public?FontButton(Context?context,?AttributeSet?attrs)?{

????????super(context,?attrs);

????????typefaceLoader?=?new?TypefaceLoader(this,?context,?attrs);

????}

?

????@Override

????public?void?setText(CharSequence?text,?BufferType?type)?{

????????super.setText(text,?type);

????????if(type?!=?BufferType.SPANNABLE?&&?typefaceLoader?!=?null){

????????????typefaceLoader.createLetterSpacing(text);

????????}

????}

}

运行效果:

  • bubuko.com,布布扣

原文:http://1105824194.iteye.com/blog/2240182

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!