android怎么引用ttf字体,android 自定义字体ttf使用的几种方法
1、首先来说下两种创建方式(1)这种要放在assets文件夹下Typeface typeface = Typeface.createFromAsset(getContext().getAssets(),"fonts/font.ttf");(2) 而这种是指定路径的Typeface typeface = Typeface.createFromFile("/mnt/sdcard/font.ttf"..
·
1、首先来说下两种创建方式
(1)这种要放在assets文件夹下
Typeface typeface = Typeface.createFromAsset(getContext().getAssets(),"fonts/font.ttf");
(2) 而这种是指定路径的
Typeface typeface = Typeface.createFromFile("/mnt/sdcard/font.ttf");
2、使用方法
(1)textview字体设置
TextView tv = (TextView)findViewById(R.id.TextView01);
tv.setTypeface(typeface);
(2)Canvas上写字字体设置
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setTypeface(typeface);
anvas.drawText(str , rect.left , rect.top+height , paint);
更多推荐
已为社区贡献3条内容
所有评论(0)