- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Android2.2API中文文档——StaticLayout2010-10-24publicclass.doc
Android2.2 API中文文档——StaticLayout
2010-10-24
public class StaticLayout extends Layout
java.lang.Object
android.text.Layout
android.text.StaticLayout
类概述
StaticLayout is a Layout for text that will not be edited after it is laid out. Use HYPERLINK /reference/android/text/DynamicLayout.html DynamicLayout for text that may change.
This is used by widgets to control text layout. You should not need to use this class directly unless you are implementing your own widget or custom display object, or would be tempted to call HYPERLINK /reference/android/graphics/Canvas.html \l drawText%28java.lang.CharSequence,%20int,%20int,%20float,%20float,%20android.graphics.Paint%29 Canvas.drawText() directly.
StaticLayout用来为不能被编辑的文字排版。对于可编辑文字的排版,可以使用类DynamicLayout实现。
该类是窗口部件用来控制文字排版使用的。通常,用户不需要直接使用这个类,除非执行自己的窗口部件或者使用用户定制的显示对象,除此情况,可直接调用 HYPERLINK /reference/android/graphics/Canvas.html \l drawText%28java.lang.CharSequence,%20int,%20int,%20float,%20float,%20android.graphics.Paint%29 Canvas.drawText()。
如下图使用一个TextView显示文本,在对文本折行时使用StaticLayout进行排版。
而下图是一个EditView实现查找功能,可以对输入的字符进行编辑,这时折行就使用DynamicLayout来实现文字的排版。
公共方法
public int getBottomPadding ()
Returns the number of extra pixels of descent padding in the bottom line of the Layout.
得到底部额外空白像素值,并返回。
public int getEllipsisCount (int line)
Returns the number of characters to be ellipsized away, or 0 if no ellipsis is to take place.
一行文字过长会在字符串结尾处用省略号代替,有省略号代替的情况下,返回的是被省略掉的字符个数,没有省略号代替时,返回0。
public int getEllipsisStart (int line)
Return the offset of the first character to be ellipsized away, relative to the start of the line. (So 0 if the beginning of the line is ellipsized, not getLineStart().)
返回第一个被省略字符的偏移值,以起始行为基准。(若指定行整行都被省略掉了,返回值是0,而不是getLineStart()得到的值)。
public int getEllipsizedWidth ()
Return the width to which this Layout is ellipsizing, or getWidth() if it is not doing anything special.
返回当前排版用被省略掉内容的宽度,如果没有做任何特殊处理返回getWidth()的值。
public boolean getLineContainsTab (int line)
Returns w
文档评论(0)