TextKt
public final class TextKt
Summary
Public methods |
|
|---|---|
static final void |
@ComposableHigh level element that displays text and provides semantics / accessibility information. |
static final void |
@ComposableHigh level element that displays text and provides semantics / accessibility information. |
static final @NonNull ProvidableCompositionLocal<@NonNull TextStyle> |
CompositionLocal containing the preferred |
Public methods
Text
@Composable
public static final void Text(
@NonNull String text,
@NonNull Modifier modifier,
@NonNull Color color,
@NonNull TextUnit fontSize,
FontStyle fontStyle,
FontWeight fontWeight,
FontFamily fontFamily,
@NonNull TextUnit letterSpacing,
TextDecoration textDecoration,
@NonNull TextAlign textAlign,
@NonNull TextUnit lineHeight,
@NonNull TextOverflow overflow,
boolean softWrap,
@IntRange(from = 1) int maxLines,
@IntRange(from = 1) int minLines,
Function1<@NonNull TextLayoutResult, Unit> onTextLayout,
TextAutoSize autoSize,
@NonNull TextStyle style
)
High level element that displays text and provides semantics / accessibility information.
The default style uses the LocalTextStyle provided by the GlimmerTheme / components. If you are setting your own style, you may want to consider first retrieving LocalTextStyle, and using TextStyle.copy to keep any theme defined attributes, only modifying the specific attributes you want to override.
For ease of use, commonly used parameters from TextStyle are also present here. The order of precedence is as follows:
-
If a parameter is explicitly set here (i.e, it is not
nullor an unspecified type), then this parameter will always be used. -
If a parameter is not set, (
nullor unspecified), then the corresponding value fromstylewill be used instead.
Additionally, for color, if color is not set, and style does not have a color, then the content color provided by the nearest surface will be used.
| Parameters | |
|---|---|
@NonNull String text |
the text to be displayed |
@NonNull Modifier modifier |
the |
@NonNull Color color |
|
@NonNull TextUnit fontSize |
the size of glyphs to use when painting the text. See |
FontStyle fontStyle |
the typeface variant to use when drawing the letters (e.g., italic). See |
FontWeight fontWeight |
the typeface thickness to use when painting the text (e.g., |
FontFamily fontFamily |
the font family to be used when rendering the text. See |
@NonNull TextUnit letterSpacing |
the amount of space to add between each letter. See |
TextDecoration textDecoration |
the decorations to paint on the text (e.g., an underline). See |
@NonNull TextAlign textAlign |
the alignment of the text within the lines of the paragraph. See |
@NonNull TextUnit lineHeight |
line height for the |
@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 |
@IntRange(from = 1) 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 |
@IntRange(from = 1) int minLines |
The minimum height in terms of minimum number of visible lines. It is required that 1 <= |
Function1<@NonNull TextLayoutResult, Unit> onTextLayout |
callback that is executed when a new text layout is calculated. A |
TextAutoSize autoSize |
Enable auto sizing for this text composable. Finds the biggest font size that fits in the available space and lays the text out with this size. This performs multiple layout passes and can be slower than using a fixed font size. This takes precedence over sizes defined through |
@NonNull TextStyle style |
style configuration for the text such as color, font, line height etc. |
Text
@Composable
public static final void Text(
@NonNull AnnotatedString text,
@NonNull Modifier modifier,
@NonNull Color color,
@NonNull TextUnit fontSize,
FontStyle fontStyle,
FontWeight fontWeight,
FontFamily fontFamily,
@NonNull TextUnit letterSpacing,
TextDecoration textDecoration,
@NonNull TextAlign textAlign,
@NonNull TextUnit lineHeight,
@NonNull TextOverflow overflow,
boolean softWrap,
@IntRange(from = 1) int maxLines,
@IntRange(from = 1) int minLines,
@NonNull Map<@NonNull String, @NonNull InlineTextContent> inlineContent,
Function1<@NonNull TextLayoutResult, Unit> onTextLayout,
TextAutoSize autoSize,
@NonNull TextStyle style
)
High level element that displays text and provides semantics / accessibility information.
The default style uses the LocalTextStyle provided by the GlimmerTheme / components. If you are setting your own style, you may want to consider first retrieving LocalTextStyle, and using TextStyle.copy to keep any theme defined attributes, only modifying the specific attributes you want to override.
For ease of use, commonly used parameters from TextStyle are also present here. The order of precedence is as follows:
-
If a parameter is explicitly set here (i.e, it is not
nullorTextUnit.Unspecified), then this parameter will always be used. -
If a parameter is not set, (
nullorTextUnit.Unspecified), then the corresponding value fromstylewill be used instead.
Additionally, for color, if color is not set, and style does not have a color, then the content color provided by the nearest surface will be used.
| Parameters | |
|---|---|
@NonNull AnnotatedString text |
the text to be displayed |
@NonNull Modifier modifier |
the |
@NonNull Color color |
|
@NonNull TextUnit fontSize |
the size of glyphs to use when painting the text. See |
FontStyle fontStyle |
the typeface variant to use when drawing the letters (e.g., italic). See |
FontWeight fontWeight |
the typeface thickness to use when painting the text (e.g., |
FontFamily fontFamily |
the font family to be used when rendering the text. See |
@NonNull TextUnit letterSpacing |
the amount of space to add between each letter. See |
TextDecoration textDecoration |
the decorations to paint on the text (e.g., an underline). See |
@NonNull TextAlign textAlign |
the alignment of the text within the lines of the paragraph. See |
@NonNull TextUnit lineHeight |
line height for the |
@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 |
@IntRange(from = 1) 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 |
@IntRange(from = 1) int minLines |
The minimum height in terms of minimum number of visible lines. It is required that 1 <= |
@NonNull Map<@NonNull String, @NonNull InlineTextContent> inlineContent |
a map storing composables that replaces certain ranges of the text, used to insert composables into text layout. See |
Function1<@NonNull TextLayoutResult, Unit> onTextLayout |
callback that is executed when a new text layout is calculated. A |
TextAutoSize autoSize |
Enable auto sizing for this text composable. Finds the biggest font size that fits in the available space and lays the text out with this size. This performs multiple layout passes and can be slower than using a fixed font size. This takes precedence over sizes defined through |
@NonNull TextStyle style |
style configuration for the text such as color, font, line height etc. |
getLocalTextStyle
public static final @NonNull ProvidableCompositionLocal<@NonNull TextStyle> getLocalTextStyle()
CompositionLocal containing the preferred TextStyle that will be used by Text components by default.