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

*** ** * ** ***


```
public final class LayoutElementBuilders.Spannable.Builder
```

<br />

*** ** * ** ***

Builder for `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable`.

## Summary

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

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable.Builder` | `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 0) https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable.Builder#addSpan(androidx.wear.protolayout.LayoutElementBuilders.Span)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Span span)` Adds one item to the `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Span` elements that form this `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable` | `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable.Builder#build()()` Builds an instance with values accumulated in this Builder. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable.Builder` | `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 0) https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable.Builder#setLineHeight(androidx.wear.protolayout.DimensionBuilders.SpProp)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.SpProp lineHeight)` Sets the explicit height between lines of text. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable.Builder` | `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 200) @https://developer.android.com/reference/androidx/wear/protolayout/expression/ProtoLayoutExperimental https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable.Builder#setMarqueeIterations(int)(@https://developer.android.com/reference/androidx/annotation/IntRange(from = "-1") int marqueeIterations)` Sets the number of times to repeat the Marquee animation. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable.Builder` | `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable.Builder#setMaxLines(int)(@https://developer.android.com/reference/androidx/annotation/IntRange(from = 1) int maxLines)` Sets the maximum number of lines that can be represented by the `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable` element. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable.Builder` | `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 0) https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable.Builder#setMaxLines(androidx.wear.protolayout.TypeBuilders.Int32Prop)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/TypeBuilders.Int32Prop maxLines)` Sets the maximum number of lines that can be represented by the `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable` element. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable.Builder` | `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 0) https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable.Builder#setModifiers(androidx.wear.protolayout.ModifiersBuilders.Modifiers)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/ModifiersBuilders.Modifiers modifiers)` Sets `https://developer.android.com/reference/androidx/wear/protolayout/ModifiersBuilders.Modifiers` for this element. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable.Builder` | `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 0) https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable.Builder#setMultilineAlignment(int)(int multilineAlignment)` Sets alignment of the `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable` content within its bounds. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable.Builder` | `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 0) https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable.Builder#setMultilineAlignment(androidx.wear.protolayout.LayoutElementBuilders.HorizontalAlignmentProp)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.HorizontalAlignmentProp multilineAlignment )` Sets alignment of the `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable` content within its bounds. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable.Builder` | `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 0) https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable.Builder#setOverflow(int)(int overflow)` Sets how to handle content which overflows the bound of the `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable` element. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable.Builder` | `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 0) https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable.Builder#setOverflow(androidx.wear.protolayout.LayoutElementBuilders.TextOverflowProp)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.TextOverflowProp overflow)` Sets how to handle content which overflows the bound of the `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable` element. |

## Public constructors

### Builder

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

```
public Builder()
```

Creates an instance of `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable.Builder`.

## Public methods

### addSpan

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

```
@RequiresSchemaVersion(major = 1, minor = 0)
public @NonNull LayoutElementBuilders.Spannable.Builder addSpan(@NonNull LayoutElementBuilders.Span span)
```

Adds one item to the `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Span` elements that form this `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable`.

### build

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

```
public @NonNull LayoutElementBuilders.Spannable build()
```

Builds an instance with values accumulated in this Builder.

### setLineHeight

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

```
@RequiresSchemaVersion(major = 1, minor = 0)
public @NonNull LayoutElementBuilders.Spannable.Builder setLineHeight(@NonNull DimensionBuilders.SpProp lineHeight)
```

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
public @NonNull LayoutElementBuilders.Spannable.Builder setMarqueeIterations(@IntRange(from = "-1") int marqueeIterations)
```

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)

```
public @NonNull LayoutElementBuilders.Spannable.Builder setMaxLines(@IntRange(from = 1) int maxLines)
```

Sets the maximum number of lines that can be represented by the `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable` element. If not defined, the `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable` 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)
public @NonNull LayoutElementBuilders.Spannable.Builder setMaxLines(@NonNull TypeBuilders.Int32Prop maxLines)
```

Sets the maximum number of lines that can be represented by the `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable` element. If not defined, the `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable` 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)
public @NonNull LayoutElementBuilders.Spannable.Builder setModifiers(@NonNull ModifiersBuilders.Modifiers modifiers)
```

Sets `https://developer.android.com/reference/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)
public @NonNull LayoutElementBuilders.Spannable.Builder setMultilineAlignment(int multilineAlignment)
```

Sets alignment of the `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable` content within its bounds. Note that a `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable` element will size itself to wrap its contents, so this option is meaningless for single-line content (for that, use alignment of the outer container). For multi-line content, however, this will set the alignment of lines relative to the `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable` 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)
public @NonNull LayoutElementBuilders.Spannable.Builder setMultilineAlignment(
    @NonNull LayoutElementBuilders.HorizontalAlignmentProp multilineAlignment
)
```

Sets alignment of the `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable` content within its bounds. Note that a `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable` element will size itself to wrap its contents, so this option is meaningless for single-line content (for that, use alignment of the outer container). For multi-line content, however, this will set the alignment of lines relative to the `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable` 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)
public @NonNull LayoutElementBuilders.Spannable.Builder setOverflow(int overflow)
```

Sets how to handle content which overflows the bound of the `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable` element. A `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable` 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 content, the content 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)
public @NonNull LayoutElementBuilders.Spannable.Builder setOverflow(@NonNull LayoutElementBuilders.TextOverflowProp overflow)
```

Sets how to handle content which overflows the bound of the `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable` element. A `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Spannable` 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 content, the content which cannot fit inside its container will be truncated. If not defined, defaults to TEXT_OVERFLOW_TRUNCATE.