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

BasicTextKt

public final class BasicTextKt


Summary

Public methods

static final void
@Composable
BasicText(
    @NonNull String text,
    @NonNull Modifier modifier,
    @NonNull TextStyle style,
    Function1<@NonNull TextLayoutResultUnit> onTextLayout,
    @NonNull TextOverflow overflow,
    boolean softWrap,
    int maxLines,
    int minLines,
    ColorProducer color
)

Basic element that displays text and provides semantics / accessibility information.

static final void
@Composable
BasicText(
    @NonNull AnnotatedString text,
    @NonNull Modifier modifier,
    @NonNull TextStyle style,
    Function1<@NonNull TextLayoutResultUnit> onTextLayout,
    @NonNull TextOverflow overflow,
    boolean softWrap,
    int maxLines,
    int minLines,
    @NonNull Map<@NonNull String, @NonNull InlineTextContent> inlineContent,
    ColorProducer color
)

Basic element that displays text and provides semantics / accessibility information.

Public methods

BasicText

@Composable
public static final void BasicText(
    @NonNull String text,
    @NonNull Modifier modifier,
    @NonNull TextStyle style,
    Function1<@NonNull TextLayoutResultUnit> onTextLayout,
    @NonNull TextOverflow overflow,
    boolean softWrap,
    int maxLines,
    int minLines,
    ColorProducer color
)

Basic element that displays text and provides semantics / accessibility information. Typically you will instead want to use androidx.compose.material.Text, which is a higher level Text element that contains semantics and consumes style information from a theme.

Parameters
@NonNull String text

The text to be displayed.

@NonNull Modifier modifier

Modifier to apply to this layout node.

@NonNull TextStyle style

Style configuration for the text such as color, font, line height etc.

Function1<@NonNull TextLayoutResultUnit> onTextLayout

Callback that is executed when a new text layout is calculated. A TextLayoutResult object that callback provides contains paragraph information, size of the text, baselines and other details. The callback can be used to add additional decoration or functionality to the text. For example, to draw selection around the text.

@NonNull TextOverflow overflow

How visual overflow should be handled.

boolean softWrap

Whether the text should break at soft line breaks. If false, the glyphs in the text will be positioned as if there was unlimited horizontal space. If softWrap is false, overflow and TextAlign may have unexpected effects.

int maxLines

An optional maximum number of lines for the text to span, wrapping if necessary. If the text exceeds the given number of lines, it will be truncated according to overflow and softWrap. It is required that 1 <= minLines<= maxLines.

int minLines

The minimum height in terms of minimum number of visible lines. It is required that 1 <= minLines<= maxLines.

ColorProducer color

Overrides the text color provided in style

BasicText

@Composable
public static final void BasicText(
    @NonNull AnnotatedString text,
    @NonNull Modifier modifier,
    @NonNull TextStyle style,
    Function1<@NonNull TextLayoutResultUnit> onTextLayout,
    @NonNull TextOverflow overflow,
    boolean softWrap,
    int maxLines,
    int minLines,
    @NonNull Map<@NonNull String, @NonNull InlineTextContent> inlineContent,
    ColorProducer color
)

Basic element that displays text and provides semantics / accessibility information. Typically you will instead want to use androidx.compose.material.Text, which is a higher level Text element that contains semantics and consumes style information from a theme.

Parameters
@NonNull AnnotatedString text

The text to be displayed.

@NonNull Modifier modifier

Modifier to apply to this layout node.

@NonNull TextStyle style

Style configuration for the text such as color, font, line height etc.

Function1<@NonNull TextLayoutResultUnit> onTextLayout

Callback that is executed when a new text layout is calculated. A TextLayoutResult object that callback provides contains paragraph information, size of the text, baselines and other details. The callback can be used to add additional decoration or functionality to the text. For example, to draw selection around the text.

@NonNull TextOverflow overflow

How visual overflow should be handled.

boolean softWrap

Whether the text should break at soft line breaks. If false, the glyphs in the text will be positioned as if there was unlimited horizontal space. If softWrap is false, overflow and TextAlign may have unexpected effects.

int maxLines

An optional maximum number of lines for the text to span, wrapping if necessary. If the text exceeds the given number of lines, it will be truncated according to overflow and softWrap. It is required that 1 <= minLines<= maxLines.

int minLines

The minimum height in terms of minimum number of visible lines. It is required that 1 <= minLines<= maxLines.

@NonNull Map<@NonNull String, @NonNull InlineTextContent> inlineContent

A map store composables that replaces certain ranges of the text. It's used to insert composables into text layout. Check InlineTextContent for more information.

ColorProducer color

Overrides the text color provided in style