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

MultiParagraph

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

Lays out and renders multiple paragraphs at once. Unlike Paragraph, supports multiple ParagraphStyles in a given text.

Summary

Public constructors
<init>(annotatedString: AnnotatedString, style: TextStyle, placeholders: List<AnnotatedString.Range<Placeholder>> = listOf(), maxLines: Int = Int.MAX_VALUE, ellipsis: Boolean = false, width: Float, density: Density, resourceLoader: Font.ResourceLoader)

Lays out a given annotatedString with the given constraints.

<init>(intrinsics: MultiParagraphIntrinsics, maxLines: Int = DefaultMaxLines, ellipsis: Boolean = false, width: Float)

Lays out and renders multiple paragraphs at once.

Public methods
ResolvedTextDirection

Get the text direction of the character at the given offset.

Rect

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

Rect
getCursorRect(offset: Int)

Returns rectangle of the cursor area.

Float
getHorizontalPosition(offset: Int, usePrimaryDirection: Boolean)

Compute the horizontal position where a newly inserted character at offset would be.

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
getLineHeight(lineIndex: Int)

Returns the height of the given line.

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 start offset of the given line, inclusive.

Float
getLineTop(lineIndex: Int)

Returns the top y coordinate of the given line.

Float
getLineWidth(lineIndex: Int)

Returns the width 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 TextRange of the word at the given character offset.

Boolean
isLineEllipsized(lineIndex: Int)

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

Unit