StaticLayout
open class StaticLayout : Layout
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
|
From class Layout
Int |
BREAK_STRATEGY_BALANCED
Value for break strategy indicating balanced line breaking. The breaks are chosen to make all lines as close to the same length as possible, including automatic hyphenation.
|
Int |
BREAK_STRATEGY_HIGH_QUALITY
Value for break strategy indicating high quality line breaking, including automatic hyphenation and doing whole-paragraph optimization of line breaks.
|
Int |
BREAK_STRATEGY_SIMPLE
Value for break strategy indicating simple line breaking. Automatic hyphens are not added (though soft hyphens are respected), and modifying text generally doesn't affect the layout before it (which yields a more consistent user experience when editing), but layout may not be the highest quality.
|
Float |
DEFAULT_LINESPACING_ADDITION
|
Float |
DEFAULT_LINESPACING_MULTIPLIER
|
Int |
DIR_LEFT_TO_RIGHT
|
Int |
DIR_RIGHT_TO_LEFT
|
Int |
HYPHENATION_FREQUENCY_FULL
Value for hyphenation frequency indicating the full amount of automatic hyphenation, typical in typography. Useful for running text and where it's important to put the maximum amount of text in a screen with limited space.
|
Int |
HYPHENATION_FREQUENCY_NONE
Value for hyphenation frequency indicating no automatic hyphenation. Useful for backward compatibility, and for cases where the automatic hyphenation algorithm results in incorrect hyphenation. Mid-word breaks may still happen when a word is wider than the layout and there is otherwise no valid break. Soft hyphens are ignored and will not be used as suggestions for potential line breaks.
|
Int |
HYPHENATION_FREQUENCY_NORMAL
Value for hyphenation frequency indicating a light amount of automatic hyphenation, which is a conservative default. Useful for informal cases, such as short sentences or chat messages.
|
Int |
JUSTIFICATION_MODE_INTER_WORD
Value for justification mode indicating the text is justified by stretching word spacing.
|
Int |
JUSTIFICATION_MODE_NONE
Value for justification mode indicating no justification.
|
|
Public constructors
|
|
|
|
|
<init>(source: CharSequence!, bufstart: Int, bufend: Int, paint: TextPaint!, outerwidth: Int, align: Layout.Alignment!, spacingmult: Float, spacingadd: Float, includepad: Boolean, ellipsize: TextUtils.TruncateAt!, ellipsizedWidth: Int)
|
Inherited functions
|
From class Layout
Unit |
draw(c: Canvas!)
Draw this Layout on the specified Canvas.
|
Unit |
draw(canvas: Canvas!, highlight: Path!, highlightPaint: Paint!, cursorOffsetVertical: Int)
Draw this Layout on the specified canvas, with the highlight path drawn between the background and the text.
|
Layout.Alignment! |
getAlignment()
Return the base alignment of this layout.
|
Unit |
getCursorPath(point: Int, dest: Path!, editingBuffer: CharSequence!)
Fills in the specified Path with a representation of a cursor at the specified offset. This will often be a vertical line but can be multiple discontinuous lines in text with multiple directionalities.
|
Float |
getDesiredWidth(source: CharSequence!, paint: TextPaint!)
Return how wide a layout must be in order to display the specified text with one line per paragraph.
As of O, Uses TextDirectionHeuristics#FIRSTSTRONG_LTR as the default text direction heuristics. In the earlier versions uses TextDirectionHeuristics#LTR as the default.
|
Float |
getDesiredWidth(source: CharSequence!, start: Int, end: Int, paint: TextPaint!)
Return how wide a layout must be in order to display the specified text slice with one line per paragraph.
As of O, Uses TextDirectionHeuristics#FIRSTSTRONG_LTR as the default text direction heuristics. In the earlier versions uses TextDirectionHeuristics#LTR as the default.
|
Int |
getHeight()
Return the total height of this layout.
|
Int |
getLineAscent(line: Int)
Get the ascent of the text on the specified line. The return value is negative to match the Paint.ascent() convention.
|
Int |
getLineBaseline(line: Int)
Return the vertical position of the baseline of the specified line.
|
Int |
getLineBottom(line: Int)
Return the vertical position of the bottom of the specified line.
|
Int |
getLineBounds(line: Int, bounds: Rect!)
Return the baseline for the specified line (0…getLineCount() - 1) If bounds is not null, return the top, left, right, bottom extents of the specified line in it.
|
Int |
getLineEnd(line: Int)
Return the text offset after the last character on the specified line.
|
Int |
getLineForOffset(offset: Int)
Get the line number on which the specified text offset appears. If you ask for a position before 0, you get 0; if you ask for a position beyond the end of the text, you get the last line.
|
Float |
getLineLeft(line: Int)
Get the leftmost position that should be exposed for horizontal scrolling on the specified line.
|
Float |
getLineMax(line: Int)
Gets the unsigned horizontal extent of the specified line, including leading margin indent, but excluding trailing whitespace.
|
Float |
getLineRight(line: Int)
Get the rightmost position that should be exposed for horizontal scrolling on the specified line.
|
Int |
getLineVisibleEnd(line: Int)
Return the text offset after the last visible character (so whitespace is not counted) on the specified line.
|
Float |
getLineWidth(line: Int)
Gets the unsigned horizontal extent of the specified line, including leading margin indent and trailing whitespace.
|
Int |
getOffsetForHorizontal(line: Int, horiz: Float)
Get the character offset on the specified line whose position is closest to the specified horizontal position.
|
Int |
getOffsetToLeftOf(offset: Int)
|
Int |
getOffsetToRightOf(offset: Int)
|
TextPaint! |
getPaint()
Return the base Paint properties for this layout. Do NOT change the paint, which may result in funny drawing for this layout.
|
Layout.Alignment! |
getParagraphAlignment(line: Int)
Get the alignment of the specified paragraph, taking into account markup attached to it.
|
Int |
getParagraphLeft(line: Int)
Get the left edge of the specified paragraph, inset by left margins.
|
Int |
getParagraphRight(line: Int)
Get the right edge of the specified paragraph, inset by right margins.
|
Float |
getPrimaryHorizontal(offset: Int)
Get the primary horizontal position for the specified text offset. This is the location where a new character would be inserted in the paragraph's primary direction.
|
Float |
getSecondaryHorizontal(offset: Int)
Get the secondary horizontal position for the specified text offset. This is the location where a new character would be inserted in the direction other than the paragraph's primary direction.
|
Unit |
getSelectionPath(start: Int, end: Int, dest: Path!)
Fills in the specified Path with a representation of a highlight between the specified offsets. This will often be a rectangle or a potentially discontinuous set of rectangles. If the start and end are the same, the returned path is empty.
|
Float |
getSpacingAdd()
Return the number of units of leading that are added to each line.
|
Float |
getSpacingMultiplier()
Return what the text height is multiplied by to get the line height.
|
CharSequence! |
getText()
Return the text that is displayed by this Layout.
|
Int |
getWidth()
Return the width of this layout.
|
Unit |
increaseWidthTo(wid: Int)
Increase the width of this layout to the specified width. Be careful to use this only when you know it is appropriate— it does not cause the text to reflow to use the full new width.
|
Boolean |
isRtlCharAt(offset: Int)
Returns true if the character at offset is right to left (RTL).
|
Boolean |
isSpanned()
|
|
Public constructors
<init>
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
getBottomPadding
open fun getBottomPadding(): Int
getEllipsisCount
open fun getEllipsisCount(line: Int): Int
getEllipsisStart
open fun getEllipsisStart(line: Int): Int
getEllipsizedWidth
open fun getEllipsizedWidth(): Int
getLineContainsTab
open fun getLineContainsTab(line: Int): Boolean
getLineCount
open fun getLineCount(): Int
getLineDescent
open fun getLineDescent(line: Int): Int
getLineForVertical
open fun getLineForVertical(vertical: Int): Int
getLineStart
open fun getLineStart(line: Int): Int
getLineTop
open fun getLineTop(line: Int): Int
getParagraphDirection
open fun getParagraphDirection(line: Int): Int
getTopPadding
open fun getTopPadding(): Int