Android 12 Developer Preview is here! Try it out, and give us your feedback!

TextLayoutResult

class TextLayoutResult
kotlin.Any
   ↳ androidx.compose.ui.text.TextLayoutResult

The data class which holds text layout result.

Summary

Public constructors
<init>(layoutInput: TextLayoutInput, multiParagraph: MultiParagraph, size: IntSize)

The data class which holds text layout result.

Public methods
TextLayoutResult
copy(layoutInput: TextLayoutInput = this.layoutInput, size: IntSize = this.size)

operator Boolean
equals(other: Any?)

ResolvedTextDirection

Get the text direction of the resolved BiDi run that the character at the given offset associated with.

Rect

Returns the bounding box of the character for given character offset.

Rect
getCursorRect(offset: Int)

Returns the rectangle of the cursor area

Float
getHorizontalPosition(offset: Int, usePrimaryDirection: Boolean)

Get the horizontal position for the specified text offset.

Float
getLineBottom(lineIndex: Int)

Returns the bottom y coordinate of the given line.

Int
getLineEnd(lineIndex: Int, visibleEnd: Boolean = false)

Returns the end offset of the given line

Int

Returns the line number on which the specified text offset appears.

Int

Returns line number closest to the given graphical vertical position.

Float
getLineLeft(lineIndex: Int)

Returns the left x coordinate of the given line.

Float
getLineRight(lineIndex: Int)

Returns the right x coordinate of the given line.

Int
getLineStart(lineIndex: Int)

Returns the end offset of the given line, inclusive.

Float
getLineTop(lineIndex: Int)

Returns the top y coordinate of the given line.

Int

Returns the character offset closest to the given graphical position.

ResolvedTextDirection

Get the text direction of the paragraph containing the given offset.

Path
getPathForRange(start: Int, end: Int)

Returns path that enclose the given text range.

TextRange

Returns the text range of the word at the given character offset.

Int

Boolean
isLineEllipsized(lineIndex: Int)

Returns true if ellipsis happens on the given line, otherwise returns false

String

Properties
Boolean

Returns true if the text is too tall and couldn't fit with given height.

Boolean

Returns true if the text is too wide and couldn't fit with given width.

Float

The distance from the top to the alphabetic baseline of the first line.

Boolean

Returns true if either vertical overflow or horizontal overflow happens.

Float

The distance from the top to the alphabetic baseline of the last line.

TextLayoutInput

The parameters used for computing this text layout result.

Int

Returns a number of lines of this text layout

MultiParagraph

The multi paragraph object.

List<Rect?>

Returns a list of bounding boxes that is reserved for TextLayoutInput.placeholders.

IntSize

The amount of space required to paint this text in Int.

Public constructors

<init>

TextLayoutResult(
    layoutInput: TextLayoutInput