- 1、本文档共4页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Android: 设置中文字体效果的一些方法开发应用程序使用最多的还是String(字符串),下面我们就如何显示String详细的说明。 引用Android SDK中显示String的函数,列举如下:drawText(String text, int start, int end, float x, float y, Paint paint)Draw the text, with origin at (x,y), using the specified paint.void drawText(char[] text, int index, int count, float x, float y, Paint paint)Draw the text, with origin at (x,y), using the specified paint.void drawText(String text, float x, float y, Paint paint)Draw the text, with origin at (x,y), using the specified paint.void drawText(CharSequence text, int start, int end, float x, float y, Paint paint)Draw the specified range of text, specified by start/end, with its origin at (x,y), in the specified Paint.void drawTextOnPath(String text, Path path, float hOffset, float vOffset, Paint paint)Draw the text, with origin at (x,y), using the specified paint, along the specified path.void drawTextOnPath(char[] text, int index, int count, Path path, float hOffset, float vOffset, Paint paint)Draw the text, with origin at (x,y), using the specified paint, along the specified path.在所有的函数中,参数主要分为3部分:字符串(String、char、CharSequence),长度(start—end、index—count),如何显示String(paint)。前2个参数一看就明白,这里我们主要介绍第3个参数Paint paint。首先,什么是Paint?引用Android SDK 中的说明,Paint类包含样式和颜色有关如何绘制几何形状,文本和位图的信息 。Canvas是一块画布,具体的文本和位图如何显示,这就是在Paint类中定义了。然后,Paint有哪些功能?在了解Paint的功能前,我们按照Word文档的功能,说明下对String的显示,有影响的因素有哪些?字体、大小(TextSize)、颜色 (TextColor)、对齐方式(TextAlign)、粗体(Bold)、斜体(Italic)、下划线(Underline)等,下面我们就按照这 些影响String显示的因素,结合Android SDK中Paint类的介绍,详细说明Paint类有哪些功能。在Android SDK中使用Typeface类来定义字体,Typeface类:指定字体和字体的固有风格,用于Paint,类似于Paint的其他 textSize,textSkewX,textScaleX一样,来说明如何绘制文本。归纳起来,Typeface类主要包括以下3个方面:一些常量的定义(BOLD,BOLD_ITALIC,ITALIC,NORMAL)常量字体的定义:字体(Typeface)说明DEFAULTThe default NORMAL typeface objectDEFAULT_BOLDThe default BOLD typeface object.MONOSPACEThe NORMAL style of the default monospace typeface.SANS_SERIFThe NORMAL style of the default sans serif typeface.SERIFThe NORMAL style of the default serif typeface.这些常量字体,在程序中是可以直接使用的,例如:Typeface. SE
文档评论(0)