class Text.Builder


Builder class for Text.

Summary

Public constructors

Builder(context: Context, text: String)

Creates a builder for a Text component with static text.

Builder(
    context: Context,
    text: TypeBuilders.StringProp,
    stringLayoutConstraint: TypeBuilders.StringLayoutConstraint
)

Creates a builder for a Text.

Public functions

Text

Constructs and returns Text with the provided content and look.

Text.Builder

Sets the color for the Text.

Text.Builder
setItalic(italic: Boolean)

Sets the text to be italic.

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

Sets the maximum lines of text.

Text.Builder

Sets the modifiers of text.

Text.Builder
setMultilineAlignment(multilineAlignment: Int)

Sets the multiline alignment for text within bounds of the Text element.

Text.Builder
setOverflow(overflow: Int)

Sets the overflow for text.

Text.Builder
setTypography(typography: Int)

Sets the typography for the Text.

Text.Builder
setUnderline(underline: Boolean)

Sets the text to be underlined.

Text.Builder
setWeight(weight: Int)

Sets the weight of the font.

Public constructors

Builder

Added in 1.0.0
Builder(context: Context, text: String)

Creates a builder for a Text component with static text.

Parameters
context: Context

The application's context.

text: String

The text content for this component.

Builder

Added in 1.0.0
Builder(
    context: Context,
    text: TypeBuilders.StringProp,
    stringLayoutConstraint: TypeBuilders.StringLayoutConstraint
)

Creates a builder for a Text.

While this component 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).

Parameters
context: Context

The application's context.

text: TypeBuilders.StringProp

The text content for this component.

stringLayoutConstraint: TypeBuilders.StringLayoutConstraint

Layout constraints used to correctly measure Text view size and align text when text has dynamic value.

Public functions

build

Added in 1.0.0
fun build(): Text

Constructs and returns Text with the provided content and look.

setColor

Added in 1.0.0
fun setColor(color: ColorBuilders.ColorProp): Text.Builder

Sets the color for the Text. If not set, onPrimary color from the DEFAULT will be used.

setItalic

Added in 1.0.0
fun setItalic(italic: Boolean): Text.Builder

Sets the text to be italic. If not set, false will be used.

setMaxLines

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

Sets the maximum lines of text. If not set, 1 will be used.

setModifiers

Added in 1.0.0
fun setModifiers(modifiers: ModifiersBuilders.Modifiers): Text.Builder

Sets the modifiers of text.

setMultilineAlignment

Added in 1.0.0
fun setMultilineAlignment(multilineAlignment: Int): Text.Builder

Sets the multiline alignment for text within bounds of the Text element. Note that this option has no effect for single line of text, and for that, alignment on the outer container should be used. If not set, TEXT_ALIGN_CENTER will be used.

setOverflow

Added in 1.0.0
fun setOverflow(overflow: Int): Text.Builder

Sets the overflow for text. If not set, TEXT_OVERFLOW_ELLIPSIZE_END will be used.

setTypography

Added in 1.0.0
fun setTypography(typography: Int): Text.Builder

Sets the typography for the Text. If not set, TYPOGRAPHY_DISPLAY1 will be used.

setUnderline

Added in 1.0.0
fun setUnderline(underline: Boolean): Text.Builder

Sets the text to be underlined. If not set, false will be used.

setWeight

Added in 1.0.0
fun setWeight(weight: Int): Text.Builder

Sets the weight of the font. If not set, default weight for the chosen Typography will be used.