Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Builder

*** ** * ** ***

Kotlin \|[Java](https://developer.android.com/reference/android/text/StaticLayout.Builder "View this page in Java")

```
class Builder
```

|---|---|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||
| ↳ | [android.text.StaticLayout.Builder](https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#) |

Builder for static layouts. The builder is the preferred pattern for constructing StaticLayout objects and should be preferred over the constructors, particularly to access newer features. To build a static layout, first call `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#obtain(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int,%20android.text.TextPaint,%20kotlin.Int)` with the required arguments (text, paint, and width), then call setters for optional parameters, and finally `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#build()` to build the StaticLayout object. Parameters not explicitly set will get default values.

## Summary

| Public methods ||
|---|---|
| [StaticLayout](https://developer.android.com/reference/kotlin/android/text/StaticLayout) | `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#build()()` Build the `https://developer.android.com/reference/kotlin/android/text/StaticLayout` after options have been set. |
| static [StaticLayout.Builder](https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#) | `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#obtain(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int,%20android.text.TextPaint,%20kotlin.Int)(source: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html, start: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html, end: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html, paint: https://developer.android.com/reference/kotlin/android/text/TextPaint, width: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Obtain a builder for constructing StaticLayout objects. |
| [StaticLayout.Builder](https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#) | `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#setAlignment(android.text.Layout.Alignment)(alignment: https://developer.android.com/reference/kotlin/android/text/Layout.Alignment)` Set the alignment. |
| [StaticLayout.Builder](https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#) | `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#setBreakStrategy(kotlin.Int)(breakStrategy: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Set break strategy, useful for selecting high quality or balanced paragraph layout options. |
| [StaticLayout.Builder](https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#) | `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#setEllipsize(android.text.TextUtils.TruncateAt)(ellipsize: https://developer.android.com/reference/kotlin/android/text/TextUtils.TruncateAt?)` Set ellipsizing on the layout. |
| [StaticLayout.Builder](https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#) | `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#setEllipsizedWidth(kotlin.Int)(ellipsizedWidth: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Set the width as used for ellipsizing purposes, if it differs from the normal layout width. |
| [StaticLayout.Builder](https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#) | `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#setHyphenationFrequency(kotlin.Int)(hyphenationFrequency: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Set hyphenation frequency, to control the amount of automatic hyphenation used. |
| [StaticLayout.Builder](https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#) | `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#setIncludePad(kotlin.Boolean)(includePad: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Set whether to include extra space beyond font ascent and descent (which is needed to avoid clipping in some languages, such as Arabic and Kannada). |
| [StaticLayout.Builder](https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#) | `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#setIndents(kotlin.IntArray,%20kotlin.IntArray)(leftIndents: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html?, rightIndents: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html?)` Set indents. |
| [StaticLayout.Builder](https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#) | `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#setJustificationMode(kotlin.Int)(justificationMode: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Set paragraph justification mode. |
| [StaticLayout.Builder](https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#) | `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#setLineBreakConfig(android.graphics.text.LineBreakConfig)(lineBreakConfig: https://developer.android.com/reference/kotlin/android/graphics/text/LineBreakConfig.html#)` Set the line break configuration. |
| [StaticLayout.Builder](https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#) | `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#setLineSpacing(kotlin.Float,%20kotlin.Float)(spacingAdd: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html, spacingMult: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)` Set line spacing parameters. |
| [StaticLayout.Builder](https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#) | `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#setMaxLines(kotlin.Int)(maxLines: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Set maximum number of lines. |
| [StaticLayout.Builder](https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#) | `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#setMinimumFontMetrics(android.graphics.Paint.FontMetrics)(minimumFontMetrics: https://developer.android.com/reference/kotlin/android/graphics/Paint.FontMetrics.html#?)` Set the minimum font metrics used for line spacing. |
| [StaticLayout.Builder](https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#) | `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#setShiftDrawingOffsetForStartOverhang(kotlin.Boolean)(shiftDrawingOffsetForStartOverhang: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Set true for shifting the drawing x offset for showing overhang at the start position. |
| [StaticLayout.Builder](https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#)! | `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#setText(kotlin.CharSequence)(source: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html!)` <br /> |
| [StaticLayout.Builder](https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#) | `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#setTextDirection(android.text.TextDirectionHeuristic)(textDir: https://developer.android.com/reference/kotlin/android/text/TextDirectionHeuristic)` Set the text direction heuristic. |
| [StaticLayout.Builder](https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#) | `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#setUseBoundsForWidth(kotlin.Boolean)(useBoundsForWidth: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Set true for using width of bounding box as a source of automatic line breaking and drawing. |
| [StaticLayout.Builder](https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#) | `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#setUseLineSpacingFromFallbacks(kotlin.Boolean)(useLineSpacingFromFallbacks: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Set whether to respect the ascent and descent of the fallback fonts that are used in displaying the text (which is needed to avoid text from consecutive lines running into each other). |

## Public methods

### build

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun build(): StaticLayout
```

Build the `https://developer.android.com/reference/kotlin/android/text/StaticLayout` after options have been set.

Note: the builder object must not be reused in any way after calling this method. Setting parameters after calling this method, or calling it a second time on the same builder object, will likely lead to unexpected results.

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/text/StaticLayout` | the newly constructed `https://developer.android.com/reference/kotlin/android/text/StaticLayout` object. This value cannot be `null`. |

### obtain

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
static fun obtain(
    source: CharSequence, 
    start: Int, 
    end: Int, 
    paint: TextPaint, 
    width: Int
): StaticLayout.Builder
```

Obtain a builder for constructing StaticLayout objects.

| Parameters ||
|---|---|
| `source` | [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html): The text to be laid out, optionally with spans. This value cannot be `null`. |
| `start` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The index of the start of the text. Value is 0 or greater |
| `end` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The index + 1 of the end of the text. Value is 0 or greater |
| `paint` | [TextPaint](https://developer.android.com/reference/kotlin/android/text/TextPaint): The base paint used for layout. This value cannot be `null`. |
| `width` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The width in pixels. Value is 0 or greater |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#` | a builder object used for constructing the StaticLayout. This value cannot be `null`. |

### setAlignment

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setAlignment(alignment: Layout.Alignment): StaticLayout.Builder
```

Set the alignment. The default is `https://developer.android.com/reference/kotlin/android/text/Layout.Alignment`.

| Parameters ||
|---|---|
| `alignment` | [Layout.Alignment](https://developer.android.com/reference/kotlin/android/text/Layout.Alignment): Alignment for the resulting `https://developer.android.com/reference/kotlin/android/text/StaticLayout` This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#` | this builder, useful for chaining. This value cannot be `null`. |

### setBreakStrategy

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setBreakStrategy(breakStrategy: Int): StaticLayout.Builder
```

Set break strategy, useful for selecting high quality or balanced paragraph layout options. The default is `https://developer.android.com/reference/kotlin/android/text/Layout#BREAK_STRATEGY_SIMPLE:kotlin.Int`.

<br />

Enabling hyphenation with either using `https://developer.android.com/reference/kotlin/android/text/Layout#HYPHENATION_FREQUENCY_NORMAL:kotlin.Int` or `https://developer.android.com/reference/kotlin/android/text/Layout#HYPHENATION_FREQUENCY_FULL:kotlin.Int` while line breaking is set to one of `https://developer.android.com/reference/kotlin/android/text/Layout#BREAK_STRATEGY_BALANCED:kotlin.Int`, `https://developer.android.com/reference/kotlin/android/text/Layout#BREAK_STRATEGY_HIGH_QUALITY:kotlin.Int` improves the structure of text layout however has performance impact and requires more time to do the text layout.

| Parameters ||
|---|---|
| `breakStrategy` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): break strategy for paragraph layout. Value is one of the following: - `https://developer.android.com/reference/kotlin/android/graphics/text/LineBreaker.html#BREAK_STRATEGY_SIMPLE:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/graphics/text/LineBreaker.html#BREAK_STRATEGY_HIGH_QUALITY:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/graphics/text/LineBreaker.html#BREAK_STRATEGY_BALANCED:kotlin.Int` |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#` | this builder, useful for chaining. This value cannot be `null`. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/widget/TextView.html#setBreakStrategy(kotlin.Int)`
- `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#setHyphenationFrequency(kotlin.Int)`

### setEllipsize

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setEllipsize(ellipsize: TextUtils.TruncateAt?): StaticLayout.Builder
```

Set ellipsizing on the layout. Causes words that are longer than the view is wide, or exceeding the number of lines (see #setMaxLines) in the case of `https://developer.android.com/reference/kotlin/android/text/TextUtils.TruncateAt` or `https://developer.android.com/reference/kotlin/android/text/TextUtils.TruncateAt`, to be ellipsized instead of broken. The default is `null`, indicating no ellipsis is to be applied.

| Parameters ||
|---|---|
| `ellipsize` | [TextUtils.TruncateAt](https://developer.android.com/reference/kotlin/android/text/TextUtils.TruncateAt)?: type of ellipsis behavior. This value may be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#` | this builder, useful for chaining |

**See Also**

- `https://developer.android.com/reference/kotlin/android/widget/TextView.html#setEllipsize(android.text.TextUtils.TruncateAt)`

### setEllipsizedWidth

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setEllipsizedWidth(ellipsizedWidth: Int): StaticLayout.Builder
```

Set the width as used for ellipsizing purposes, if it differs from the normal layout width. The default is the `width` passed to `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#obtain(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int,%20android.text.TextPaint,%20kotlin.Int)`.

| Parameters ||
|---|---|
| `ellipsizedWidth` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): width used for ellipsizing, in pixels. Value is 0 or greater |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#` | this builder, useful for chaining. This value cannot be `null`. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/widget/TextView.html#setEllipsize(android.text.TextUtils.TruncateAt)`

### setHyphenationFrequency

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setHyphenationFrequency(hyphenationFrequency: Int): StaticLayout.Builder
```

Set hyphenation frequency, to control the amount of automatic hyphenation used. The possible values are defined in `https://developer.android.com/reference/kotlin/android/text/Layout`, by constants named with the pattern `HYPHENATION_FREQUENCY_*`. The default is `https://developer.android.com/reference/kotlin/android/text/Layout#HYPHENATION_FREQUENCY_NONE:kotlin.Int`.

<br />

Enabling hyphenation with either using `https://developer.android.com/reference/kotlin/android/text/Layout#HYPHENATION_FREQUENCY_NORMAL:kotlin.Int` or `https://developer.android.com/reference/kotlin/android/text/Layout#HYPHENATION_FREQUENCY_FULL:kotlin.Int` while line breaking is set to one of `https://developer.android.com/reference/kotlin/android/text/Layout#BREAK_STRATEGY_BALANCED:kotlin.Int`, `https://developer.android.com/reference/kotlin/android/text/Layout#BREAK_STRATEGY_HIGH_QUALITY:kotlin.Int` improves the structure of text layout however has performance impact and requires more time to do the text layout.

| Parameters ||
|---|---|
| `hyphenationFrequency` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): hyphenation frequency for the paragraph. Value is one of the following: - `https://developer.android.com/reference/kotlin/android/text/Layout#HYPHENATION_FREQUENCY_NORMAL:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/text/Layout#HYPHENATION_FREQUENCY_NORMAL_FAST:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/text/Layout#HYPHENATION_FREQUENCY_FULL:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/text/Layout#HYPHENATION_FREQUENCY_FULL_FAST:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/text/Layout#HYPHENATION_FREQUENCY_NONE:kotlin.Int` |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#` | this builder, useful for chaining. This value cannot be `null`. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/widget/TextView.html#setHyphenationFrequency(kotlin.Int)`
- `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#setBreakStrategy(kotlin.Int)`

### setIncludePad

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setIncludePad(includePad: Boolean): StaticLayout.Builder
```

Set whether to include extra space beyond font ascent and descent (which is needed to avoid clipping in some languages, such as Arabic and Kannada). The default is `true`.

| Parameters ||
|---|---|
| `includePad` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): whether to include padding |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#` | this builder, useful for chaining. This value cannot be `null`. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/widget/TextView.html#setIncludeFontPadding(kotlin.Boolean)`

### setIndents

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setIndents(
    leftIndents: IntArray?, 
    rightIndents: IntArray?
): StaticLayout.Builder
```

Set indents. Arguments are arrays holding an indent amount, one per line, measured in pixels. For lines past the last element in the array, the last element repeats.

| Parameters ||
|---|---|
| `leftIndents` | [IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html)?: array of indent values for left margin, in pixels. This value may be `null`. |
| `rightIndents` | [IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html)?: array of indent values for right margin, in pixels. This value may be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#` | this builder, useful for chaining. This value cannot be `null`. |

### setJustificationMode

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setJustificationMode(justificationMode: Int): StaticLayout.Builder
```

Set paragraph justification mode. The default value is `https://developer.android.com/reference/kotlin/android/text/Layout#JUSTIFICATION_MODE_NONE:kotlin.Int`. If the last line is too short for justification, the last line will be displayed with the alignment set by `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#setAlignment(android.text.Layout.Alignment)`. When Justification mode is JUSTIFICATION_MODE_INTER_WORD, wordSpacing on the given `https://developer.android.com/reference/kotlin/android/graphics/Paint.html#` will be ignored. This behavior also affects Spans which change the wordSpacing.

| Parameters ||
|---|---|
| `justificationMode` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): justification mode for the paragraph. Value is one of the following: - `https://developer.android.com/reference/kotlin/android/graphics/text/LineBreaker.html#JUSTIFICATION_MODE_NONE:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/graphics/text/LineBreaker.html#JUSTIFICATION_MODE_INTER_WORD:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/graphics/text/LineBreaker.html#JUSTIFICATION_MODE_INTER_CHARACTER:kotlin.Int` |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#` | this builder, useful for chaining. This value cannot be `null`. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/graphics/Paint.html#setWordSpacing(kotlin.Float)`

### setLineBreakConfig

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setLineBreakConfig(lineBreakConfig: LineBreakConfig): StaticLayout.Builder
```

Set the line break configuration. The line break will be passed to native used for calculating the text wrapping. The default value of the line break style is `https://developer.android.com/reference/kotlin/android/graphics/text/LineBreakConfig.html#LINE_BREAK_STYLE_NONE:kotlin.Int`

| Parameters ||
|---|---|
| `lineBreakConfig` | [LineBreakConfig](https://developer.android.com/reference/kotlin/android/graphics/text/LineBreakConfig.html#): the line break configuration for text wrapping. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#` | this builder, useful for chaining. This value cannot be `null`. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/widget/TextView.html#setLineBreakStyle(kotlin.Int)`
- `https://developer.android.com/reference/kotlin/android/widget/TextView.html#setLineBreakWordStyle(kotlin.Int)`

### setLineSpacing

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setLineSpacing(
    spacingAdd: Float, 
    spacingMult: Float
): StaticLayout.Builder
```

Set line spacing parameters. Each line will have its line spacing multiplied by `spacingMult` and then increased by `spacingAdd`. The default is 0.0 for `spacingAdd` and 1.0 for `spacingMult`.

| Parameters ||
|---|---|
| `spacingAdd` | [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html): the amount of line spacing addition |
| `spacingMult` | [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html): the line spacing multiplier. Value is 0.0f or greater |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#` | this builder, useful for chaining. This value cannot be `null`. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/widget/TextView.html#setLineSpacing(kotlin.Float,%20kotlin.Float)`

### setMaxLines

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setMaxLines(maxLines: Int): StaticLayout.Builder
```

Set maximum number of lines. This is particularly useful in the case of ellipsizing, where it changes the layout of the last line. The default is unlimited.

| Parameters ||
|---|---|
| `maxLines` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): maximum number of lines in the layout. Value is 0 or greater |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#` | this builder, useful for chaining. This value cannot be `null`. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/widget/TextView.html#setMaxLines(kotlin.Int)`

### setMinimumFontMetrics

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setMinimumFontMetrics(minimumFontMetrics: Paint.FontMetrics?): StaticLayout.Builder
```

Set the minimum font metrics used for line spacing.

`null` is the default value. If `null` is set or left as default, the font metrics obtained by `https://developer.android.com/reference/kotlin/android/graphics/Paint.html#getFontMetricsForLocale(android.graphics.Paint.FontMetrics)` is used.

The minimum meaning here is the minimum value of line spacing: maximum value of `https://developer.android.com/reference/kotlin/android/graphics/Paint.html#ascent()`, minimum value of `https://developer.android.com/reference/kotlin/android/graphics/Paint.html#descent()`.

By setting this value, each line will have minimum line spacing regardless of the text rendered. For example, usually Japanese script has larger vertical metrics than Latin script. By setting the metrics obtained by `https://developer.android.com/reference/kotlin/android/graphics/Paint.html#getFontMetricsForLocale(android.graphics.Paint.FontMetrics)` for Japanese or leave it `null` if the Paint's locale is Japanese, the line spacing for Japanese is reserved if the text is an English text. If the vertical metrics of the text is larger than Japanese, for example Burmese, the bigger font metrics is used.

| Parameters ||
|---|---|
| `minimumFontMetrics` | [Paint.FontMetrics](https://developer.android.com/reference/kotlin/android/graphics/Paint.FontMetrics.html#)?: A minimum font metrics. Passing `null` for using the value obtained by `https://developer.android.com/reference/kotlin/android/graphics/Paint.html#getFontMetricsForLocale(android.graphics.Paint.FontMetrics)` |

**See Also**

- `https://developer.android.com/reference/kotlin/android/widget/TextView.html#setMinimumFontMetrics(android.graphics.Paint.FontMetrics)`
- `https://developer.android.com/reference/kotlin/android/widget/TextView.html#getMinimumFontMetrics()`
- `https://developer.android.com/reference/kotlin/android/text/Layout#getMinimumFontMetrics()`
- `https://developer.android.com/reference/kotlin/android/text/Layout.Builder#setMinimumFontMetrics(android.graphics.Paint.FontMetrics)`
- `https://developer.android.com/reference/kotlin/android/text/DynamicLayout.Builder#setMinimumFontMetrics(android.graphics.Paint.FontMetrics)`

### setShiftDrawingOffsetForStartOverhang

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setShiftDrawingOffsetForStartOverhang(shiftDrawingOffsetForStartOverhang: Boolean): StaticLayout.Builder
```

Set true for shifting the drawing x offset for showing overhang at the start position. This flag is ignored if the `https://developer.android.com/reference/kotlin/android/text/Layout#getUseBoundsForWidth()` is false. If this value is false, the Layout draws text from the zero even if there is a glyph stroke in a region where the x coordinate is negative. If this value is true, the Layout draws text with shifting the x coordinate of the drawing bounding box. This value is false by default.

| Parameters ||
|---|---|
| `shiftDrawingOffsetForStartOverhang` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): true for shifting the drawing offset for showing the stroke that is in the region where the x coordinate is negative. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#` | This value cannot be `null`. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#setUseBoundsForWidth(kotlin.Boolean)`
- `https://developer.android.com/reference/kotlin/android/text/Layout#getUseBoundsForWidth()`

### setText

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setText(source: CharSequence!): StaticLayout.Builder!
```

### setTextDirection

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setTextDirection(textDir: TextDirectionHeuristic): StaticLayout.Builder
```

Set the text direction heuristic. The text direction heuristic is used to resolve text direction per-paragraph based on the input text. The default is `https://developer.android.com/reference/kotlin/android/text/TextDirectionHeuristics#FIRSTSTRONG_LTR:android.text.TextDirectionHeuristic`.

| Parameters ||
|---|---|
| `textDir` | [TextDirectionHeuristic](https://developer.android.com/reference/kotlin/android/text/TextDirectionHeuristic): text direction heuristic for resolving bidi behavior. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#` | this builder, useful for chaining. This value cannot be `null`. |

### setUseBoundsForWidth

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setUseBoundsForWidth(useBoundsForWidth: Boolean): StaticLayout.Builder
```

Set true for using width of bounding box as a source of automatic line breaking and drawing. If this value is false, the Layout determines the drawing offset and automatic line breaking based on total advances. By setting true, use all joined glyph's bounding boxes as a source of text width. If the font has glyphs that have negative bearing X or its xMax is greater than advance, the glyph clipping can happen because the drawing area may be bigger. By setting this to true, the Layout will reserve more spaces for drawing.

| Parameters ||
|---|---|
| `useBoundsForWidth` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): True for using bounding box, false for advances. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#` | this builder instance. This value cannot be `null`. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/text/Layout#getUseBoundsForWidth()`
- `https://developer.android.com/reference/kotlin/android/text/Layout.Builder#setUseBoundsForWidth(kotlin.Boolean)`

### setUseLineSpacingFromFallbacks

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setUseLineSpacingFromFallbacks(useLineSpacingFromFallbacks: Boolean): StaticLayout.Builder
```

Set whether to respect the ascent and descent of the fallback fonts that are used in displaying the text (which is needed to avoid text from consecutive lines running into each other). If set, fallback fonts that end up getting used can increase the ascent and descent of the lines that they are used on.

For backward compatibility reasons, the default is `false`, but setting this to true is strongly recommended. It is required to be true if text could be in languages like Burmese or Tibetan where text is typically much taller or deeper than Latin text.

| Parameters ||
|---|---|
| `useLineSpacingFromFallbacks` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): whether to expand linespacing based on fallback fonts |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#` | this builder, useful for chaining. This value cannot be `null`. |