LayoutElementBuilders.Text.Builder


class LayoutElementBuilders.Text.Builder


Builder for Text.

Summary

Public constructors

Creates an instance of Builder.

Public functions

LayoutElementBuilders.Text

Builds an instance with values accumulated in this Builder.

LayoutElementBuilders.Text.Builder

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

LayoutElementBuilders.Text.Builder
@RequiresSchemaVersion(major = 1, minor = 200)
setLayoutConstraintsForDynamicText(
    stringLayoutConstraint: TypeBuilders.StringLayoutConstraint
)

Sets the bounding constraints for the layout affected by the dynamic value from setText}.

LayoutElementBuilders.Text.Builder
@RequiresSchemaVersion(major = 1, minor = 0)
setLineHeight(lineHeight: DimensionBuilders.SpProp)

Sets the explicit height between lines of text.

LayoutElementBuilders.Text.Builder
@RequiresSchemaVersion(major = 1, minor = 200)
@ProtoLayoutExperimental
setMarqueeIterations(marqueeIterations: @IntRange(from = "-1") Int)

Sets the number of times to repeat the Marquee animation.

LayoutElementBuilders.Text.Builder
setMaxLines(maxLines: @IntRange(from = 1) Int)

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

LayoutElementBuilders.Text.Builder
@RequiresSchemaVersion(major = 1, minor = 0)
setMaxLines(maxLines: TypeBuilders.Int32Prop)

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

LayoutElementBuilders.Text.Builder
@RequiresSchemaVersion(major = 1, minor = 0)
setModifiers(modifiers: ModifiersBuilders.Modifiers)

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

LayoutElementBuilders.Text.Builder
@RequiresSchemaVersion(major = 1, minor = 0)
setMultilineAlignment(multilineAlignment: Int)

Sets alignment of the text within its bounds.

LayoutElementBuilders.Text.Builder
@RequiresSchemaVersion(major = 1, minor = 0)
setMultilineAlignment(
    multilineAlignment: LayoutElementBuilders.TextAlignmentProp
)

Sets alignment of the text within its bounds.

LayoutElementBuilders.Text.Builder
@RequiresSchemaVersion(major = 1, minor = 0)
setOverflow(overflow: Int)

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

LayoutElementBuilders.Text.Builder

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

LayoutElementBuilders.Text.Builder
@RequiresSchemaVersion(major = 1, minor = 0)
setText(text: String)

Sets the static text to render.

LayoutElementBuilders.Text.Builder
@RequiresSchemaVersion(major = 1, minor = 0)
setText(text: TypeBuilders.StringProp)

Sets the text to render.

Public constructors

Builder

Added in 1.0.0
Builder()

Creates an instance of Builder.

Public functions

build

Added in 1.0.0
fun build(): LayoutElementBuilders.Text

Builds an instance with values accumulated in this Builder.

setFontStyle

Added in 1.0.0
@RequiresSchemaVersion(major = 1, minor = 0)
fun setFontStyle(fontStyle: LayoutElementBuilders.FontStyle): LayoutElementBuilders.Text.Builder

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

setLayoutConstraintsForDynamicText

Added in 1.0.0
@RequiresSchemaVersion(major = 1, minor = 200)
fun setLayoutConstraintsForDynamicText(
    stringLayoutConstraint: TypeBuilders.StringLayoutConstraint
): LayoutElementBuilders.Text.Builder

Sets the bounding constraints for the layout affected by the dynamic value from setText}.

setLineHeight

Added in 1.0.0
@RequiresSchemaVersion(major = 1, minor = 0)
fun setLineHeight(lineHeight: DimensionBuilders.SpProp): LayoutElementBuilders.Text.Builder

Sets 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.

setMarqueeIterations

Added in 1.0.0
@RequiresSchemaVersion(major = 1, minor = 200)
@ProtoLayoutExperimental
fun setMarqueeIterations(marqueeIterations: @IntRange(from = "-1") Int): LayoutElementBuilders.Text.Builder

Sets 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.

setMaxLines

Added in 1.0.0
fun setMaxLines(maxLines: @IntRange(from = 1) Int): LayoutElementBuilders.Text.Builder

Sets 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.

setMaxLines

Added in 1.0.0
@RequiresSchemaVersion(major = 1, minor = 0)
fun setMaxLines(maxLines: TypeBuilders.Int32Prop): LayoutElementBuilders.Text.Builder

Sets 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.

setMultilineAlignment

Added in 1.0.0
@RequiresSchemaVersion(major = 1, minor = 0)
fun setMultilineAlignment(multilineAlignment: Int): LayoutElementBuilders.Text.Builder

Sets 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.

setMultilineAlignment

Added in 1.0.0
@RequiresSchemaVersion(major = 1, minor = 0)
fun setMultilineAlignment(
    multilineAlignment: LayoutElementBuilders.TextAlignmentProp
): LayoutElementBuilders.Text.Builder

Sets 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.

setOverflow

Added in 1.0.0
@RequiresSchemaVersion(major = 1, minor = 0)
fun setOverflow(overflow: Int): LayoutElementBuilders.Text.Builder

Sets how to handle text which overflows the bound of the Text element. A Text 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.

setOverflow

Added in 1.0.0
@RequiresSchemaVersion(major = 1, minor = 0)
fun setOverflow(overflow: LayoutElementBuilders.TextOverflowProp): LayoutElementBuilders.Text.Builder

Sets how to handle text which overflows the bound of the Text element. A Text 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.

setText

Added in 1.0.0
@RequiresSchemaVersion(major = 1, minor = 0)
fun setText(text: String): LayoutElementBuilders.Text.Builder

Sets the static text to render.

setText

Added in 1.0.0
@RequiresSchemaVersion(major = 1, minor = 0)
fun setText(text: TypeBuilders.StringProp): LayoutElementBuilders.Text.Builder

Sets 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.