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

ParagraphKt

public final class ParagraphKt


Summary

Public methods

static final @NonNull Paragraph
Paragraph(
    @NonNull ParagraphIntrinsics paragraphIntrinsics,
    @NonNull Constraints constraints,
    int maxLines,
    boolean ellipsis
)

Lays out the text in ParagraphIntrinsics with the given constraints.

static final @NonNull Paragraph
Paragraph(
    @NonNull ParagraphIntrinsics paragraphIntrinsics,
    int maxLines,
    boolean ellipsis,
    float width
)

This method is deprecated. Paragraph that takes maximum allowed width is deprecated, pass constraints instead.

static final @NonNull Paragraph
Paragraph(
    @NonNull String text,
    @NonNull TextStyle style,
    @NonNull Constraints constraints,
    @NonNull Density density,
    @NonNull FontFamily.Resolver fontFamilyResolver,
    @NonNull List<@NonNull AnnotatedString.Range<@NonNull SpanStyle>> spanStyles,
    @NonNull List<@NonNull AnnotatedString.Range<@NonNull Placeholder>> placeholders,
    int maxLines,
    boolean ellipsis
)

Lays out a given text with the given constraints.

static final @NonNull Paragraph
Paragraph(
    @NonNull String text,
    @NonNull TextStyle style,
    @NonNull List<@NonNull AnnotatedString.Range<@NonNull SpanStyle>> spanStyles,
    @NonNull List<@NonNull AnnotatedString.Range<@NonNull Placeholder>> placeholders,
    int maxLines,
    boolean ellipsis,
    float width,
    @NonNull Density density,
    @NonNull Font.ResourceLoader resourceLoader
)

This method is deprecated. Font.ResourceLoader is deprecated, instead pass FontFamily.Resolver

static final @NonNull Paragraph
Paragraph(
    @NonNull String text,
    @NonNull TextStyle style,
    float width,
    @NonNull Density density,
    @NonNull FontFamily.Resolver fontFamilyResolver,
    @NonNull List<@NonNull AnnotatedString.Range<@NonNull SpanStyle>> spanStyles,
    @NonNull List<@NonNull AnnotatedString.Range<@NonNull Placeholder>> placeholders,
    int maxLines,
    boolean ellipsis
)

This method is deprecated. Paragraph that takes maximum allowed width is deprecated, pass constraints instead.

Public methods

Paragraph

public static final @NonNull Paragraph Paragraph(
    @NonNull ParagraphIntrinsics paragraphIntrinsics,
    @NonNull Constraints constraints,
    int maxLines,
    boolean ellipsis
)

Lays out the text in ParagraphIntrinsics with the given constraints. A paragraph is a text that has a single ParagraphStyle.

Parameters
@NonNull ParagraphIntrinsics paragraphIntrinsics

ParagraphIntrinsics instance

@NonNull Constraints constraints

how wide and tall the text is allowed to be. Constraints.maxWidth will define the width of the Paragraph. Constraints.maxHeight helps defining the number of lines that fit with ellipsis is true. Minimum components of the Constraints object are no-op.

int maxLines

the maximum number of lines that the text can have

boolean ellipsis

whether to ellipsize text, applied only when maxLines is set

Paragraph

public static final @NonNull Paragraph Paragraph(
    @NonNull ParagraphIntrinsics paragraphIntrinsics,
    int maxLines,
    boolean ellipsis,
    float width
)

Lays out the text in ParagraphIntrinsics with the given constraints. A paragraph is a text that has a single ParagraphStyle.

Parameters
@NonNull ParagraphIntrinsics paragraphIntrinsics

ParagraphIntrinsics instance

int maxLines

the maximum number of lines that the text can have

boolean ellipsis

whether to ellipsize text, applied only when maxLines is set

float width

how wide the text is allowed to be

Paragraph

public static final @NonNull Paragraph Paragraph(
    @NonNull String text,
    @NonNull TextStyle style,
    @NonNull Constraints constraints,
    @NonNull Density density,
    @NonNull FontFamily.Resolver fontFamilyResolver,
    @NonNull List<@NonNull AnnotatedString.Range<@NonNull SpanStyle>> spanStyles,
    @NonNull List<@NonNull AnnotatedString.Range<@NonNull Placeholder>> placeholders,
    int maxLines,
    boolean ellipsis
)

Lays out a given text with the given constraints. A paragraph is a text that has a single ParagraphStyle.

If the style does not contain any androidx.compose.ui.text.style.TextDirection, androidx.compose.ui.text.style.TextDirection.Content is used as the default value.

Parameters
@NonNull String text

the text to be laid out

@NonNull TextStyle style

the TextStyle to be applied to the whole text

@NonNull Constraints constraints

how wide and tall the text is allowed to be. Constraints.maxWidth will define the width of the Paragraph. Constraints.maxHeight helps defining the number of lines that fit with ellipsis is true. Minimum components of the Constraints object are no-op.

@NonNull Density density

density of the device

@NonNull FontFamily.Resolver fontFamilyResolver

FontFamily.Resolver to be used to load the font given in SpanStyles

@NonNull List<@NonNull AnnotatedString.Range<@NonNull SpanStyle>> spanStyles

SpanStyles to be applied to parts of text

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

a list of placeholder metrics which tells Paragraph where should be left blank to leave space for inline elements.

int maxLines

the maximum number of lines that the text can have

boolean ellipsis

whether to ellipsize text, applied only when maxLines is set

Paragraph

public static final @NonNull Paragraph Paragraph(
    @NonNull String text,
    @NonNull TextStyle style,
    @NonNull List<@NonNull AnnotatedString.Range<@NonNull SpanStyle>> spanStyles,
    @NonNull List<@NonNull AnnotatedString.Range<@NonNull Placeholder>> placeholders,
    int maxLines,
    boolean ellipsis,
    float width,
    @NonNull Density density,
    @NonNull Font.ResourceLoader resourceLoader
)

Lays out a given text with the given constraints. A paragraph is a text that has a single ParagraphStyle.

If the style does not contain any androidx.compose.ui.text.style.TextDirection, androidx.compose.ui.text.style.TextDirection.Content is used as the default value.

Parameters
@NonNull String text

the text to be laid out

@NonNull TextStyle style

the TextStyle to be applied to the whole text

@NonNull List<@NonNull AnnotatedString.Range<@NonNull SpanStyle>> spanStyles

SpanStyles to be applied to parts of text

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

a list of placeholder metrics which tells Paragraph where should be left blank to leave space for inline elements.

int maxLines

the maximum number of lines that the text can have

boolean ellipsis

whether to ellipsize text, applied only when maxLines is set

float width

how wide the text is allowed to be

@NonNull Density density

density of the device

@NonNull Font.ResourceLoader resourceLoader

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

Paragraph

public static final @NonNull Paragraph Paragraph(
    @NonNull String text,
    @NonNull TextStyle style,
    float width,
    @NonNull Density density,
    @NonNull FontFamily.Resolver fontFamilyResolver,
    @NonNull List<@NonNull AnnotatedString.Range<@NonNull SpanStyle>> spanStyles,
    @NonNull List<@NonNull AnnotatedString.Range<@NonNull Placeholder>> placeholders,
    int maxLines,
    boolean ellipsis
)

Lays out a given text with the given constraints. A paragraph is a text that has a single ParagraphStyle.

If the style does not contain any androidx.compose.ui.text.style.TextDirection, androidx.compose.ui.text.style.TextDirection.Content is used as the default value.

Parameters
@NonNull String text

the text to be laid out

@NonNull TextStyle style

the TextStyle to be applied to the whole text

float width

how wide the text is allowed to be

@NonNull Density density

density of the device

@NonNull FontFamily.Resolver fontFamilyResolver

FontFamily.Resolver to be used to load the font given in SpanStyles

@NonNull List<@NonNull AnnotatedString.Range<@NonNull SpanStyle>> spanStyles

SpanStyles to be applied to parts of text

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

a list of placeholder metrics which tells Paragraph where should be left blank to leave space for inline elements.

int maxLines

the maximum number of lines that the text can have

boolean ellipsis

whether to ellipsize text, applied only when maxLines is set