# LayoutElementBuilders.Text

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

*** ** * ** ***


```
@RequiresSchemaVersion(major = 1, minor = 0)
public final class LayoutElementBuilders.Text implements LayoutElementBuilders.LayoutElement
```

<br />

*** ** * ** ***

A text string.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Text.Builder` Builder for `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Text`. |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.FontStyle` | `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Text#getFontStyle()()` Gets the style of font to use (size, bold etc). |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/wear/protolayout/TypeBuilders.StringLayoutConstraint` | `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Text#getLayoutConstraintsForDynamicText()()` Gets the bounding constraints for the layout affected by the dynamic value from `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Text#getText()`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.SpProp` | `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Text#getLineHeight()()` Gets the explicit height between lines of text. |
| `@https://developer.android.com/reference/androidx/annotation/IntRange(from = "-1") int` | `@https://developer.android.com/reference/androidx/wear/protolayout/expression/ProtoLayoutExperimental https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Text#getMarqueeIterations()()` Gets the number of times to repeat the Marquee animation. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/wear/protolayout/TypeBuilders.Int32Prop` | `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Text#getMaxLines()()` Gets the maximum number of lines that can be represented by the `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Text` element. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/wear/protolayout/ModifiersBuilders.Modifiers` | `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Text#getModifiers()()` Gets `https://developer.android.com/reference/androidx/wear/protolayout/ModifiersBuilders.Modifiers` for this element. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.TextAlignmentProp` | `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Text#getMultilineAlignment()()` Gets alignment of the text within its bounds. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.TextOverflowProp` | `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Text#getOverflow()()` Gets how to handle text which overflows the bound of the `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Text` element. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/wear/protolayout/TypeBuilders.StringProp` | `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Text#getText()()` Gets the text to render. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Text#toString()()` |

## Public methods

### getFontStyle

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

```
public @Nullable LayoutElementBuilders.FontStyle getFontStyle()
```

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](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.0.0)

```
public @Nullable TypeBuilders.StringLayoutConstraint getLayoutConstraintsForDynamicText()
```

Gets the bounding constraints for the layout affected by the dynamic value from `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Text#getText()`.

### getLineHeight

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

```
public @Nullable DimensionBuilders.SpProp getLineHeight()
```

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](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.0.0)

```
@ProtoLayoutExperimental
public @IntRange(from = "-1") int getMarqueeIterations()
```

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](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.0.0)

```
public @Nullable TypeBuilders.Int32Prop getMaxLines()
```

Gets the maximum number of lines that can be represented by the `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Text` element. If not defined, the `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Text` element will be treated as a single-line element.

### getModifiers

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

```
public @Nullable ModifiersBuilders.Modifiers getModifiers()
```

Gets `https://developer.android.com/reference/androidx/wear/protolayout/ModifiersBuilders.Modifiers` for this element.

### getMultilineAlignment

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

```
public @Nullable LayoutElementBuilders.TextAlignmentProp getMultilineAlignment()
```

Gets alignment of the text within its bounds. Note that a `https://developer.android.com/reference/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 `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Text` element bounds. If not defined, defaults to TEXT_ALIGN_CENTER.

### getOverflow

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

```
public @Nullable LayoutElementBuilders.TextOverflowProp getOverflow()
```

Gets how to handle text which overflows the bound of the `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Text` element. A `https://developer.android.com/reference/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.

### getText

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

```
public @Nullable TypeBuilders.StringProp getText()
```

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

### toString

```
public @NonNull String toString()
```