LayoutElementBuilders.Text


@RequiresSchemaVersion(major = 1, minor = 0)
class LayoutElementBuilders.Text : LayoutElementBuilders.LayoutElement


A text string.

Summary

Nested types

Builder for Text.

Public functions

LayoutElementBuilders.FontStyle?

Gets the style of font to use (size, bold etc).

TypeBuilders.StringLayoutConstraint?

Gets the bounding constraints for the layout affected by the dynamic value from getText.

DimensionBuilders.SpProp?

Gets the explicit height between lines of text.

@IntRange(from = "-1") Int

Gets the number of times to repeat the Marquee animation.

TypeBuilders.Int32Prop?

Gets the maximum number of lines that can be represented by the Text element.

ModifiersBuilders.Modifiers?

Gets androidx.wear.protolayout.ModifiersBuilders.Modifiers for this element.

LayoutElementBuilders.TextAlignmentProp?

Gets alignment of the text within its bounds.

LayoutElementBuilders.TextOverflowProp?

Gets how to handle text which overflows the bound of the Text element.

TypeBuilders.StringProp?

Gets the text to render.

String

Public functions

getFontStyle

Added in 1.0.0
fun getFontStyle(): LayoutElementBuilders.FontStyle?

Gets the style of font to use (size, bold etc). If not specified, defaults to the platform's default body font.

getLayoutConstraintsForDynamicText

Added in 1.0.0
fun getLayoutConstraintsForDynamicText(): TypeBuilders.StringLayoutConstraint?

Gets the bounding constraints for the layout affected by the dynamic value from getText.

getLineHeight

Added in 1.0.0
fun getLineHeight(): DimensionBuilders.SpProp?

Gets the explicit height between lines of text. This is equivalent to the vertical distance between subsequent baselines. If not specified, defaults the font's recommended interline spacing.

getMarqueeIterations

Added in 1.0.0
@ProtoLayoutExperimental
fun getMarqueeIterations(): @IntRange(from = "-1") Int

Gets the number of times to repeat the Marquee animation. Only applies when overflow is TEXT_OVERFLOW_MARQUEE. Set to -1 to repeat indefinitely. Defaults to repeat indefinitely.

getMaxLines

Added in 1.0.0
fun getMaxLines(): TypeBuilders.Int32Prop?

Gets the maximum number of lines that can be represented by the Text element. If not defined, the Text element will be treated as a single-line element.

getMultilineAlignment

Added in 1.0.0
fun getMultilineAlignment(): LayoutElementBuilders.TextAlignmentProp?

Gets alignment of the text within its bounds. Note that a Text element will size itself to wrap its contents, so this option is meaningless for single-line text (for that, use alignment of the outer container). For multi-line text, however, this will set the alignment of lines relative to the Text element bounds. If not defined, defaults to TEXT_ALIGN_CENTER.

getOverflow

Added in 1.0.0
fun getOverflow(): LayoutElementBuilders.TextOverflowProp?

Gets how to handle text which overflows the bound of the Text element. A element will grow as large as possible inside its parent container (while still respecting max_lines); if it cannot grow large enough to render all of its text, the text which cannot fit inside its container will be truncated. If not defined, defaults to TEXT_OVERFLOW_TRUNCATE.

getText

Added in 1.0.0
fun getText(): TypeBuilders.StringProp?

Gets the text to render.

While this field is statically accessible from 1.0, it's only bindable since version 1.2 and renderers supporting version 1.2 will use the dynamic value (if set).

When using a dynamic value, make sure to specify the bounding constraints for the affected layout element through setLayoutConstraintsForDynamicText(StringLayoutConstraint) otherwise build() fails.

toString

fun toString(): String