码迷,mamicode.com
首页 > 其他好文 > 详细

TextView-显示自己添加的字体样式

时间:2015-03-16 15:47:09      阅读:97      评论:0      收藏:0      [点我收藏+]

标签:

1.首先要把我们的字体放到手机的目录下,

我们的字体是放到了/system/fonts/ 目录下面了

2.在代码中进行设置

import android.graphics.Paint;
import android.graphics.Typeface;
import java.io.File;




private static final String SYSTEM = "/system/fonts/";
private static final String SYSTEM_FONT_TIME_BACKGROUND = SYSTEM + "FunuiNumber-Regular.ttf";
private static Typeface sClockTypeface;
private static Typeface sStandardTypeface;


 mDisResult = (TextView) findViewById(R.id.dis_result);
File fileTTF = new File(SYSTEM_FONT_TIME_BACKGROUND);
sStandardTypeface = Typeface.DEFAULT;
 if (sClockTypeface == null && fileTTF.exists()) {
 sClockTypeface = Typeface
             .createFromFile(SYSTEM_FONT_TIME_BACKGROUND);
       }
  Paint paint = mDisResult.getPaint();
  paint.setTypeface(fileTTF.exists() ? sClockTypeface : sStandardTypeface);

 

TextView-显示自己添加的字体样式

标签:

原文地址:http://www.cnblogs.com/zhangshuli-1989/p/zhangshuli_typeface_150316142.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!