Android中Paint字体属性的设置
来源:互联网 发布:linux怎么udp端口测试 编辑:程序博客网 时间:2024/05/17 01:35
Android中Paint字体属性的设置
(转)
在Android SDK中使用Typeface类来定义字体,可以通过常用字体类型名称进行设置,如设置默认黑体:
Paint mp = new paint();
mp.setTypeface(Typeface.DEFAULT_BOLD)
mp.setTypeface(Typeface.DEFAULT_BOLD)
常用的字体类型名称还有:
Paint mp = new Paint();
Typeface font = Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD);
p.setTypeface( font );
Typeface font = Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD);
p.setTypeface( font );
常用的字体风格名称还有:
但是有时上面那些设置在绘图过程中是不起作用的,所以还有如下设置方式:
Paint mp = new Paint();
mp.setFakeBoldText(true); //true为粗体,false为非粗体
mp.setTextSkewX(-0.5f); //float类型参数,负数表示右斜,整数左斜
mp.setUnderlineText(true); //true为下划线,false为非下划线
mp.setStrikeThruText(true); //true为删除线,false为非删除线
mp.setFakeBoldText(true); //true为粗体,false为非粗体
mp.setTextSkewX(-0.5f); //float类型参数,负数表示右斜,整数左斜
mp.setUnderlineText(true); //true为下划线,false为非下划线
mp.setStrikeThruText(true); //true为删除线,false为非删除线
Paint常用的方法还有:
mp.setTextSize(); //设置字体大小,int型,如12
mp.setStrokeWidth(w); //设置线宽,float型,如2.5f,默认绘文本无需设置(默认值好像为0),但假如设置了,再绘制文本的时候一定要恢复到0
mp.setStrokeWidth(w); //设置线宽,float型,如2.5f,默认绘文本无需设置(默认值好像为0),但假如设置了,再绘制文本的时候一定要恢复到0
说明:对于中文粗体的设置,好像只能通过setFakeBoldText(true)来实现,尽管效果看起来不是很实在(字体中空效果)。实际发现,最后绘制的效果与手机硬件也有些关系,比如前面的绘图测试程序,在HTC里面黑体中文一行压根没显示(英文和数字是正常的),而斜体一行倒显示了,只是没有斜体效果。魅族M9表现的很给力,可能是M9定制的Android系统里面字体库比较丰富吧!
- Android中Paint字体属性的设置
- Android中Paint字体属性的设置
- Android中Paint字体属性的设置
- Android中Paint字体属性的设置
- Android中Paint字体属性的设置
- Android中Paint字体属性的设置
- Android中Paint字体属性的设置
- Android中Paint字体属性的设置
- Android中Paint字体属性的一些设置
- Android中Paint字体属性的一些设置
- Android中 Paint 字体、粗细等属性的一些设置
- Android中 Paint 字体、粗细等属性的一些设置
- Android中设置TextView的字体和设置Paint画笔的字体属性
- 【Android】Android中 Paint 字体、粗细等属性的一些设置
- 【Android】Android中 Paint 字体、粗细等属性的一些设置
- 【Android】Android中 Paint 字体、粗细等属性的一些设置
- 【Android】Android中 Paint 字体、粗细等属性的一些设置
- Android字体属性Paint.FontMetrics
- 按回车表单自动提交问题
- ubuntu 安装新版本 redis
- myeclipse 10 安装Fat jar打包插件以及如何使用fat打包工具
- 开箱即用!Android四款系统架构工具
- java util包学习(8)Map源码分析
- Android中Paint字体属性的设置
- opencv 正脸和侧脸检测
- 事件的封装
- Java对Oracle中Clob类型数据的读取和写入
- 多线程Event的使用例子
- C++ Virtual函数 .
- utorrent RSS + remote
- JavaScript中的事件处理
- Ruby的对象模型