StaticLayout
open class StaticLayout : Layout
| kotlin.Any | ||
| ↳ | android.text.Layout | |
| ↳ | android.text.StaticLayout | |
StaticLayout is a Layout for text that will not be edited after it is laid out. Use 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 Canvas.drawText() directly.
Summary
| Nested classes | |
|---|---|
|
Builder for static layouts. |
|
| Inherited constants | |
|---|---|
| Public constructors | |
|---|---|
StaticLayout(source: CharSequence!, paint: TextPaint!, width: Int, align: Layout.Alignment!, spacingmult: Float, spacingadd: Float, includepad: Boolean) |
|
StaticLayout(source: CharSequence!, bufstart: Int, bufend: Int, paint: TextPaint!, outerwidth: Int, align: Layout.Alignment!, spacingmult: Float, spacingadd: Float, includepad: Boolean) |
|
StaticLayout(source: CharSequence!, bufstart: Int, bufend: Int, paint: TextPaint!, outerwidth: Int, align: Layout.Alignment!, spacingmult: Float, spacingadd: Float, includepad: Boolean, ellipsize: TextUtils.TruncateAt!, ellipsizedWidth: Int) |
|
| Public methods | |
|---|---|
| open RectF |
Get an actual bounding box that draws text content. |
| open Int |
Returns the number of extra pixels of descent padding in the bottom line of the Layout. |
| open Int |
getEllipsisCount(line: Int)Returns the number of characters to be ellipsized away, or 0 if no ellipsis is to take place. |
| open Int |
getEllipsisStart(line: Int)Return the offset of the first character to be ellipsized away, relative to the start of the line. |
| open Boolean |
getLineContainsTab(line: Int)Returns whether the specified line contains one or more characters that need to be handled specially, like tabs. |
| open Int |
Return the number of lines of text in this layout. |
| open Int |
getLineDescent(line: Int)Return the descent of the specified line(0…getLineCount() - 1). |
| Layout.Directions! |
getLineDirections(line: Int)Returns the directional run information for the specified line. |
| open Int |
getLineForVertical(vertical: Int)Get the line number corresponding to the specified vertical position. |
| open Int |
getLineStart(line: Int)Return the text offset of the beginning of the specified line ( 0…getLineCount()). |
| open Int |
getLineTop(line: Int)Return the vertical position of the top of the specified line (0…getLineCount()). |
| open Int |
getParagraphDirection(line: Int)Returns the primary directionality of the paragraph containing the specified line, either 1 for left-to-right lines, or -1 for right-to-left lines (see |
| open Int |
Returns the (negative) number of extra pixels of ascent padding in the top line of the Layout. |
| Inherited functions | |
|---|---|
| Inherited properties | |
|---|---|
Public constructors
StaticLayout
StaticLayout(
source: CharSequence!,
paint: TextPaint!,
width: Int,
align: Layout.Alignment!,
spacingmult: Float,
spacingadd: Float,
includepad: Boolean)
Deprecated: Use Builder instead.
StaticLayout
StaticLayout(
source: CharSequence!,
bufstart: Int,
bufend: Int,
paint: TextPaint!,
outerwidth: Int,
align: Layout.Alignment!,
spacingmult: Float,
spacingadd: Float,
includepad: Boolean)
Deprecated: Use Builder instead.
StaticLayout
StaticLayout(
source: CharSequence!,
bufstart: Int,
bufend: Int,
paint: TextPaint!,
outerwidth: Int,
align: Layout.Alignment!,
spacingmult: Float,
spacingadd: Float,
includepad: Boolean,
ellipsize: TextUtils.TruncateAt!,
ellipsizedWidth: Int)
Deprecated: Use Builder instead.
Public methods
computeDrawingBoundingBox
open fun computeDrawingBoundingBox(): RectF
Get an actual bounding box that draws text content. Note that the RectF.top and RectF.bottom may be different from the Layout.getLineTop(int) of the first line and Layout.getLineBottom(int) of the last line. The line top and line bottom are calculated based on yMin/yMax or ascent/descent value of font file. On the other hand, the drawing bounding boxes are calculated based on actual glyphs used there.
| Return | |
|---|---|
RectF |
This value cannot be null. |
getBottomPadding
open fun getBottomPadding(): Int
Returns the number of extra pixels of descent padding in the bottom line of the Layout.
getEllipsisCount
open fun getEllipsisCount(line: Int): Int
Returns the number of characters to be ellipsized away, or 0 if no ellipsis is to take place.
getEllipsisStart
open fun getEllipsisStart(line: Int): Int
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().)
getLineContainsTab
open fun getLineContainsTab(line: Int): Boolean
Returns whether the specified line contains one or more characters that need to be handled specially, like tabs.
getLineCount
open fun getLineCount(): Int
Return the number of lines of text in this layout.
getLineDescent
open fun getLineDescent(line: Int): Int
Return the descent of the specified line(0…getLineCount() - 1).
getLineDirections
fun getLineDirections(line: Int): Layout.Directions!
Returns the directional run information for the specified line. The array alternates counts of characters in left-to-right and right-to-left segments of the line.
NOTE: this is inadequate to support bidirectional text, and will change.
getLineForVertical
open fun getLineForVertical(vertical: Int): Int
Get the line number corresponding to the specified vertical position. If you ask for a position above 0, you get 0; if you ask for a position below the bottom of the text, you get the last line.
getLineStart
open fun getLineStart(line: Int): Int
Return the text offset of the beginning of the specified line ( 0…getLineCount()). If the specified line is equal to the line count, returns the length of the text.
getLineTop
open fun getLineTop(line: Int): Int
Return the vertical position of the top of the specified line (0…getLineCount()). If the specified line is equal to the line count, returns the bottom of the last line.
getParagraphDirection
open fun getParagraphDirection(line: Int): Int
Returns the primary directionality of the paragraph containing the specified line, either 1 for left-to-right lines, or -1 for right-to-left lines (see DIR_LEFT_TO_RIGHT, DIR_RIGHT_TO_LEFT).
getTopPadding
open fun getTopPadding(): Int
Returns the (negative) number of extra pixels of ascent padding in the top line of the Layout.