Android 字体图片设置

使用字体图片,图片属性更容易设置,图片如同字体一样,可设置颜色,大小,以下为使用步骤

1.到  Iconfont-阿里巴巴矢量图标库 注册账号,首页图标说明:


2.图标的选择与下载


3.下载文件说明(Android部分)


4.在项目中使用,把3中的ttf文件放在assets文件夹下:

5.代码应用,若按照阿里矢量图标官网的使用方法,则相当麻烦,为简单使用可自定义View,直接当作控件使用:

自定义控件代码:

package com.doctor.doctorhelper.view;

import android.content.Context;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.TextView;

/**
 * Created by public on 2016/12/22.
 */
public class IconFontTextView extends TextView{
    public IconFontTextView(Context context) {
        super(context);
        init(context);
    }

    public IconFontTextView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public IconFontTextView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }

    private void init(Context context){
        Typeface iconfont=Typeface.createFromAsset(context.getAssets(),"iconfont/iconfont.ttf");
        setTypeface(iconfont);
    }
}

可直接使用,设置大小,颜色:




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值