{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

MultiParagraphIntrinsics

public final class MultiParagraphIntrinsics implements ParagraphIntrinsics


Calculates and provides the intrinsic width and height of text that contains ParagraphStyle.

Throws
kotlin.IllegalArgumentException

if ParagraphStyle.textDirection is not set, or any of the placeholders crosses paragraph boundary.

See also
MultiParagraph
Placeholder

Summary

Public constructors

MultiParagraphIntrinsics(
    @NonNull AnnotatedString annotatedString,
    @NonNull TextStyle style,
    @NonNull List<@NonNull AnnotatedString.Range<@NonNull Placeholder>> placeholders,
    @NonNull Density density,
    @NonNull FontFamily.Resolver fontFamilyResolver
)
MultiParagraphIntrinsics(
    @NonNull AnnotatedString annotatedString,
    @NonNull TextStyle style,
    @NonNull List<@NonNull AnnotatedString.Range<@NonNull Placeholder>> placeholders,
    @NonNull Density density,
    @NonNull Font.ResourceLoader resourceLoader
)

This method is deprecated. Font.ResourceLoader is deprecated, call with fontFamilyResolver

Public methods

final @NonNull AnnotatedString

the text to be laid out

boolean

Any Paragraph rendered using this ParagraphIntrinsics will be measured and drawn using stale resolved fonts.

float

Returns the smallest width beyond which increasing the width never decreases the height.

float

The width for text if all soft wrap opportunities were taken.

final @NonNull List<@NonNull AnnotatedString.Range<@NonNull Placeholder>>

a list of Placeholders that specify ranges of text which will be skipped during layout and replaced with Placeholder.

Public constructors

MultiParagraphIntrinsics

public MultiParagraphIntrinsics(
    @NonNull AnnotatedString annotatedString,
    @NonNull TextStyle style,
    @NonNull List<@NonNull AnnotatedString.Range<@NonNull Placeholder>> placeholders,
    @NonNull Density density,
    @NonNull FontFamily.Resolver fontFamilyResolver
)
Parameters
@NonNull AnnotatedString annotatedString

the text to be laid out

@NonNull TextStyle style

the TextStyle to be applied to the whole text

@NonNull List<@NonNull AnnotatedString.Range<@NonNull Placeholder>> placeholders

a list of Placeholders that specify ranges of text which will be skipped during layout and replaced with Placeholder. It's required that the range of each Placeholder doesn't cross paragraph boundary, otherwise IllegalArgumentException is thrown.

@NonNull Density density

density of the device

@NonNull FontFamily.Resolver fontFamilyResolver

Font.ResourceLoader to be used to load the font given in SpanStyles

MultiParagraphIntrinsics

public MultiParagraphIntrinsics(
    @NonNull AnnotatedString annotatedString,
    @NonNull TextStyle style,
    @NonNull List<@NonNull AnnotatedString.Range<@NonNull Placeholder>> placeholders,
    @NonNull Density density,
    @NonNull Font.ResourceLoader resourceLoader
)

Public methods

getAnnotatedString

public final @NonNull AnnotatedString getAnnotatedString()

the text to be laid out

getHasStaleResolvedFonts

public boolean getHasStaleResolvedFonts()

Any Paragraph rendered using this ParagraphIntrinsics will be measured and drawn using stale resolved fonts.

If this is false, this ParagraphIntrinsics is using the most current font resolution from FontFamily.Resolver.

If this is true, recreating this ParagraphIntrinsics will use new fonts from FontFamily.Resolver for both display and measurement. Recreating this ParagraphIntrinsics and displaying the resulting Paragraph causes user-visible reflow of the displayed text.

Once true, this will never become false without recreating this ParagraphIntrinsics.

It is discouraged, but safe, to continue to use this object after this becomes true. The only impact of using this object after hasStaleResolvedFonts becomes true is stale resolutions of async fonts for measurement and display.

getMaxIntrinsicWidth

public float getMaxIntrinsicWidth()

Returns the smallest width beyond which increasing the width never decreases the height.

getMinIntrinsicWidth

public float getMinIntrinsicWidth()

The width for text if all soft wrap opportunities were taken.

getPlaceholders

public final @NonNull List<@NonNull AnnotatedString.Range<@NonNull Placeholder>> getPlaceholders()

a list of Placeholders that specify ranges of text which will be skipped during layout and replaced with Placeholder. It's required that the range of each Placeholder doesn't cross paragraph boundary, otherwise IllegalArgumentException is thrown.