# LayoutElementBuilders.Text.Builder

# LayoutElementBuilders.Text.Builder

Artifact:[androidx.wear.protolayout:protolayout](https://developer.android.com/jetpack/androidx/releases/wear-protolayout)  
[View Source](https://cs.android.com/search?q=file:androidx/wear/protolayout/LayoutElementBuilders.java+class:androidx.wear.protolayout.LayoutElementBuilders.Text.Builder)  
Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.0.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Text.Builder "View this page in Java")

<br />

```
class LayoutElementBuilders.Text.Builder
```

<br />

*** ** * ** ***

Builder for[Text](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text).

## Summary

|                                                                                                                              ### Public constructors                                                                                                                               |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text.Builder#Builder())`()` Creates an instance of[Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text.Builder). |

|                                                               ### Public functions                                                                |
|---------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [LayoutElementBuilders.Text](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text)                 | [build](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text.Builder#build())`()` Builds an instance with values accumulated in this Builder.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| [LayoutElementBuilders.Text.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text.Builder) | `@`[RequiresSchemaVersion](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/RequiresSchemaVersion)`(major = 1, minor = 0)` [setFontStyle](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text.Builder#setFontStyle(androidx.wear.protolayout.LayoutElementBuilders.FontStyle))`(fontStyle: `[LayoutElementBuilders.FontStyle](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.FontStyle)`)` Sets the style of font to use (size, bold etc).                                                                                                                                                                                                                                                                                                |
| [LayoutElementBuilders.Text.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text.Builder) | `@`[RequiresSchemaVersion](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/RequiresSchemaVersion)`(major = 1, minor = 200)` [setLayoutConstraintsForDynamicText](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text.Builder#setLayoutConstraintsForDynamicText(androidx.wear.protolayout.TypeBuilders.StringLayoutConstraint))`(` ` stringLayoutConstraint: `[TypeBuilders.StringLayoutConstraint](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/TypeBuilders.StringLayoutConstraint) `)` Sets the bounding constraints for the layout affected by the dynamic value from[setText](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text.Builder#setText(androidx.wear.protolayout.TypeBuilders.StringProp))}. |
| [LayoutElementBuilders.Text.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text.Builder) | `@`[RequiresSchemaVersion](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/RequiresSchemaVersion)`(major = 1, minor = 0)` [setLineHeight](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text.Builder#setLineHeight(androidx.wear.protolayout.DimensionBuilders.SpProp))`(lineHeight: `[DimensionBuilders.SpProp](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/DimensionBuilders.SpProp)`)` Sets the explicit height between lines of text.                                                                                                                                                                                                                                                                                                                  |
| [LayoutElementBuilders.Text.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text.Builder) | `@`[RequiresSchemaVersion](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/RequiresSchemaVersion)`(major = 1, minor = 200)` `@`[ProtoLayoutExperimental](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/ProtoLayoutExperimental) [setMarqueeIterations](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text.Builder#setMarqueeIterations(int))`(marqueeIterations: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = "-1") `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Sets the number of times to repeat the Marquee animation.                                                                                                                                |
| [LayoutElementBuilders.Text.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text.Builder) | [setMaxLines](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text.Builder#setMaxLines(int))`(maxLines: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 1) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Sets the maximum number of lines that can be represented by the[Text](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text)element.                                                                                                                                                                                                                                                                                                                                               |
| [LayoutElementBuilders.Text.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text.Builder) | `@`[RequiresSchemaVersion](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/RequiresSchemaVersion)`(major = 1, minor = 0)` [setMaxLines](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text.Builder#setMaxLines(androidx.wear.protolayout.TypeBuilders.Int32Prop))`(maxLines: `[TypeBuilders.Int32Prop](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/TypeBuilders.Int32Prop)`)` Sets the maximum number of lines that can be represented by the[Text](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text)element.                                                                                                                                                                                           |
| [LayoutElementBuilders.Text.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text.Builder) | `@`[RequiresSchemaVersion](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/RequiresSchemaVersion)`(major = 1, minor = 0)` [setModifiers](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text.Builder#setModifiers(androidx.wear.protolayout.ModifiersBuilders.Modifiers))`(modifiers: `[ModifiersBuilders.Modifiers](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ModifiersBuilders.Modifiers)`)` Sets[androidx.wear.protolayout.ModifiersBuilders.Modifiers](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ModifiersBuilders.Modifiers)for this element.                                                                                                                                                                         |
| [LayoutElementBuilders.Text.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text.Builder) | `@`[RequiresSchemaVersion](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/RequiresSchemaVersion)`(major = 1, minor = 0)` [setMultilineAlignment](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text.Builder#setMultilineAlignment(int))`(multilineAlignment: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Sets alignment of the text within its bounds.                                                                                                                                                                                                                                                                                                                                                                                             |
| [LayoutElementBuilders.Text.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text.Builder) | `@`[RequiresSchemaVersion](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/RequiresSchemaVersion)`(major = 1, minor = 0)` [setMultilineAlignment](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text.Builder#setMultilineAlignment(androidx.wear.protolayout.LayoutElementBuilders.TextAlignmentProp))`(` ` multilineAlignment: `[LayoutElementBuilders.TextAlignmentProp](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.TextAlignmentProp) `)` Sets alignment of the text within its bounds.                                                                                                                                                                                                                                          |
| [LayoutElementBuilders.Text.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text.Builder) | `@`[RequiresSchemaVersion](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/RequiresSchemaVersion)`(major = 1, minor = 0)` [setOverflow](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text.Builder#setOverflow(int))`(overflow: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Sets how to handle text which overflows the bound of the[Text](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text)element.                                                                                                                                                                                                                                                                                             |
| [LayoutElementBuilders.Text.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text.Builder) | `@`[RequiresSchemaVersion](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/RequiresSchemaVersion)`(major = 1, minor = 0)` [setOverflow](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text.Builder#setOverflow(androidx.wear.protolayout.LayoutElementBuilders.TextOverflowProp))`(overflow: `[LayoutElementBuilders.TextOverflowProp](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.TextOverflowProp)`)` Sets how to handle text which overflows the bound of the[Text](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text)element.                                                                                                                                                  |
| [LayoutElementBuilders.Text.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text.Builder) | `@`[RequiresSchemaVersion](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/RequiresSchemaVersion)`(major = 1, minor = 0)` [setText](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text.Builder#setText(java.lang.String))`(text: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`)` Sets the static text to render.                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| [LayoutElementBuilders.Text.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text.Builder) | `@`[RequiresSchemaVersion](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/RequiresSchemaVersion)`(major = 1, minor = 0)` [setText](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text.Builder#setText(androidx.wear.protolayout.TypeBuilders.StringProp))`(text: `[TypeBuilders.StringProp](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/TypeBuilders.StringProp)`)` Sets the text to render.                                                                                                                                                                                                                                                                                                                                                              |

## Public constructors

### Builder

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.0.0)  

```
Builder()
```

Creates an instance of[Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text.Builder).  

## Public functions

### build

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.0.0)  

```
fun build(): LayoutElementBuilders.Text
```

Builds an instance with values accumulated in this Builder.  

### setFontStyle

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#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](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#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](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text.Builder#setText(androidx.wear.protolayout.TypeBuilders.StringProp))}.  

### setLineHeight

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#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](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#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](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#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](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text)element. If not defined, the[Text](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text)element will be treated as a single-line element.  

### setMaxLines

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#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](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text)element. If not defined, the[Text](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text)element will be treated as a single-line element.  

### setModifiers

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.0.0)  

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

Sets[androidx.wear.protolayout.ModifiersBuilders.Modifiers](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ModifiersBuilders.Modifiers)for this element.  

### setMultilineAlignment

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#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](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.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](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text)element bounds. If not defined, defaults to TEXT_ALIGN_CENTER.  

### setMultilineAlignment

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#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](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.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](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text)element bounds. If not defined, defaults to TEXT_ALIGN_CENTER.  

### setOverflow

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#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](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text)element. A[Text](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.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](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#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](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Text)element. A[Text](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.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](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#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](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#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).