# Layout.Builder

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

# Builder

*** ** * ** ***

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

```
class Builder
```

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

A builder class for Layout object. Different from[StaticLayout.Builder](https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder), this builder generates the optimal layout based on input. If the given text and parameters can be rendered with[BoringLayout](https://developer.android.com/reference/kotlin/android/text/BoringLayout), this builder generates[BoringLayout](https://developer.android.com/reference/kotlin/android/text/BoringLayout)instance. Otherwise,[StaticLayout](https://developer.android.com/reference/kotlin/android/text/StaticLayout)instance is generated.

## Summary

|                                                                                                                                                                                                                                                                                                                                        Public constructors                                                                                                                                                                                                                                                                                                                                        ||
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [Builder](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#Builder(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int,%20android.text.TextPaint,%20kotlin.Int))`(`text:` `[CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)`, `start:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `end:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `paint:` `[TextPaint](https://developer.android.com/reference/kotlin/android/text/TextPaint)`, `width:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Construct a builder class. |

|                                                                                                                                                                                                                                        Public methods                                                                                                                                                                                                                                         ||
|-----------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Layout](https://developer.android.com/reference/kotlin/android/text/Layout)                  | [build](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#build())`()` Build a Layout object.                                                                                                                                                                                                                                                                         |
| [Layout.Builder](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#) | [setAlignment](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#setAlignment(android.text.Layout.Alignment))`(`alignment:` `[Layout.Alignment](https://developer.android.com/reference/kotlin/android/text/Layout.Alignment)`)` Set the text alignment.                                                                                                              |
| [Layout.Builder](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#) | [setBreakStrategy](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#setBreakStrategy(kotlin.Int))`(`breakStrategy:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Set the line break strategy.                                                                                                                                      |
| [Layout.Builder](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#) | [setEllipsize](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#setEllipsize(android.text.TextUtils.TruncateAt))`(`ellipsize:` `[TextUtils.TruncateAt](https://developer.android.com/reference/kotlin/android/text/TextUtils.TruncateAt)?`)` Set the ellipsizing type.                                                                                               |
| [Layout.Builder](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#) | [setEllipsizedWidth](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#setEllipsizedWidth(kotlin.Int))`(`ellipsizeWidth:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Set the width as used for ellipsizing purpose in pixels.                                                                                                     |
| [Layout.Builder](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#) | [setFallbackLineSpacingEnabled](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#setFallbackLineSpacingEnabled(kotlin.Boolean))`(`fallbackLineSpacing:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Set whether to respect the ascent and descent of the fallback fonts.                                                  |
| [Layout.Builder](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#) | [setFontPaddingIncluded](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#setFontPaddingIncluded(kotlin.Boolean))`(`includeFontPadding:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Set whether including extra padding into the first and the last line height.                                                         |
| [Layout.Builder](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#) | [setHyphenationFrequency](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#setHyphenationFrequency(kotlin.Int))`(`hyphenationFrequency:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Set the hyphenation frequency.                                                                                                               |
| [Layout.Builder](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#) | [setJustificationMode](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#setJustificationMode(kotlin.Int))`(`justificationMode:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Set justification mode.                                                                                                                               |
| [Layout.Builder](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#) | [setLeftIndents](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#setLeftIndents(kotlin.IntArray))`(`leftIndents:` `[IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html)?`)` Set visually left indents in pixels per lines.                                                                                                         |
| [Layout.Builder](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#) | [setLineBreakConfig](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#setLineBreakConfig(android.graphics.text.LineBreakConfig))`(`lineBreakConfig:` `[LineBreakConfig](https://developer.android.com/reference/kotlin/android/graphics/text/LineBreakConfig.html#)`)` Set the line break configuration.                                                             |
| [Layout.Builder](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#) | [setLineSpacingAmount](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#setLineSpacingAmount(kotlin.Float))`(`amount:` `[Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)`)` Set the line spacing amount.                                                                                                                               |
| [Layout.Builder](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#) | [setLineSpacingMultiplier](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#setLineSpacingMultiplier(kotlin.Float))`(`multiplier:` `[Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)`)` Set the line spacing multiplier.                                                                                                               |
| [Layout.Builder](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#) | [setMaxLines](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#setMaxLines(kotlin.Int))`(`maxLines:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Set the maximum number of lines.                                                                                                                                                 |
| [Layout.Builder](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#) | [setMinimumFontMetrics](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#setMinimumFontMetrics(android.graphics.Paint.FontMetrics))`(`minimumFontMetrics:` `[Paint.FontMetrics](https://developer.android.com/reference/kotlin/android/graphics/Paint.FontMetrics.html#)?`)` Set the minimum font metrics used for line spacing.                                     |
| [Layout.Builder](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#) | [setRightIndents](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#setRightIndents(kotlin.IntArray))`(`rightIndents:` `[IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html)?`)` Set visually right indents in pixels per lines.                                                                                                     |
| [Layout.Builder](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#) | [setShiftDrawingOffsetForStartOverhang](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#setShiftDrawingOffsetForStartOverhang(kotlin.Boolean))`(`shiftDrawingOffsetForStartOverhang:` `[Boolean](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. |
| [Layout.Builder](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#) | [setTextDirectionHeuristic](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#setTextDirectionHeuristic(android.text.TextDirectionHeuristic))`(`textDirection:` `[TextDirectionHeuristic](https://developer.android.com/reference/kotlin/android/text/TextDirectionHeuristic)`)` Set the text direction heuristics.                                                   |
| [Layout.Builder](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#) | [setUseBoundsForWidth](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#setUseBoundsForWidth(kotlin.Boolean))`(`useBoundsForWidth:` `[Boolean](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.                                              |

## Public constructors

### Builder

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

```
Builder(
    text: CharSequence, 
    start: Int, 
    end: Int, 
    paint: TextPaint, 
    width: Int)
```

Construct a builder class.

|                                                                             Parameters                                                                              ||
|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `text`  | [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html):a text to be displayed. This value cannot be`null`.          |
| `start` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):an inclusive start index of the text to be displayed. Value is 0 or greater     |
| `end`   | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):an exclusive end index of the text to be displayed. Value is 0 or greater       |
| `paint` | [TextPaint](https://developer.android.com/reference/kotlin/android/text/TextPaint):a paint object to be used for drawing text. This value cannot be`null`. |
| `width` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):a width constraint in pixels. Value is 0 or greater                             |

## Public methods

### build

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

```
fun build(): Layout
```

Build a Layout object.

|                                                  Return                                                   ||
|------------------------------------------------------------------------------|-----------------------------|
| [Layout](https://developer.android.com/reference/kotlin/android/text/Layout) | This value cannot be`null`. |

### setAlignment

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

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

Set the text alignment. The default value is[Layout.Alignment.ALIGN_NORMAL](https://developer.android.com/reference/kotlin/android/text/Layout.Alignment).

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

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

**See Also**

- [android.text.Layout.Alignment](https://developer.android.com/reference/kotlin/android/text/Layout.Alignment)
- [android.text.Layout#getAlignment()](https://developer.android.com/reference/kotlin/android/text/Layout#getAlignment())
- [android.text.StaticLayout.Builder#setAlignment(Alignment)](https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#setAlignment(android.text.Layout.Alignment))  

### setBreakStrategy

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

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

Set the line break strategy. The default value is[Layout.BREAK_STRATEGY_SIMPLE](https://developer.android.com/reference/kotlin/android/text/Layout#BREAK_STRATEGY_SIMPLE:kotlin.Int).

|                                                                                                                                                                                                                                                                                                                                                    Parameters                                                                                                                                                                                                                                                                                                                                                    ||
|-----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `breakStrategy` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):a break strategy for line breaking. Value is[android.graphics.text.LineBreaker#BREAK_STRATEGY_SIMPLE](https://developer.android.com/reference/kotlin/android/graphics/text/LineBreaker.html#BREAK_STRATEGY_SIMPLE:kotlin.Int),[android.graphics.text.LineBreaker#BREAK_STRATEGY_HIGH_QUALITY](https://developer.android.com/reference/kotlin/android/graphics/text/LineBreaker.html#BREAK_STRATEGY_HIGH_QUALITY:kotlin.Int), or[android.graphics.text.LineBreaker#BREAK_STRATEGY_BALANCED](https://developer.android.com/reference/kotlin/android/graphics/text/LineBreaker.html#BREAK_STRATEGY_BALANCED:kotlin.Int) |

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

**See Also**

- [android.text.Layout#getBreakStrategy()](https://developer.android.com/reference/kotlin/android/text/Layout#getBreakStrategy())
- [android.text.StaticLayout.Builder#setBreakStrategy(int)](https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#setBreakStrategy(kotlin.Int))
- [android.text.Layout#BREAK_STRATEGY_SIMPLE](https://developer.android.com/reference/kotlin/android/text/Layout#BREAK_STRATEGY_SIMPLE:kotlin.Int)
- [android.text.Layout#BREAK_STRATEGY_HIGH_QUALITY](https://developer.android.com/reference/kotlin/android/text/Layout#BREAK_STRATEGY_HIGH_QUALITY:kotlin.Int)
- [android.text.Layout#BREAK_STRATEGY_BALANCED](https://developer.android.com/reference/kotlin/android/text/Layout#BREAK_STRATEGY_BALANCED:kotlin.Int)  

### setEllipsize

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

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

Set the ellipsizing type. By setting null, the ellipsize is disabled. The default value is`null`.

|                                                                                 Parameters                                                                                  ||
|-------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `ellipsize` | [TextUtils.TruncateAt](https://developer.android.com/reference/kotlin/android/text/TextUtils.TruncateAt)?:type of the ellipsize. null for disabling ellipsize. |

|                                                        Return                                                         ||
|-----------------------------------------------------------------------------------------------|------------------------|
| [Layout.Builder](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#) | this builder instance. |

**See Also**

- [android.text.Layout#getEllipsize()](https://developer.android.com/reference/kotlin/android/text/Layout#getEllipsize())
- [android.text.StaticLayout.Builder#getEllipsize()](https://developer.android.com/reference/kotlin/android/text/Layout#getEllipsize())
- [android.text.TextUtils.TruncateAt](https://developer.android.com/reference/kotlin/android/text/TextUtils.TruncateAt)  

### setEllipsizedWidth

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

```
fun setEllipsizedWidth(ellipsizeWidth: Int): Layout.Builder
```

Set the width as used for ellipsizing purpose in pixels. The passed value is ignored and forced to set to the value of width constraint passed in constructor if no ellipsize option is set. The default value is the width constraint.

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

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

**See Also**

- [android.text.Layout#getEllipsizedWidth()](https://developer.android.com/reference/kotlin/android/text/Layout#getEllipsizedWidth())
- [android.text.StaticLayout.Builder#setEllipsizedWidth(int)](https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#setEllipsizedWidth(kotlin.Int))  

### setFallbackLineSpacingEnabled

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

```
fun setFallbackLineSpacingEnabled(fallbackLineSpacing: Boolean): Layout.Builder
```

Set whether to respect the ascent and descent of the fallback fonts. 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. The default value is`false`

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

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

**See Also**

- [android.text.Layout#isFallbackLineSpacingEnabled()](https://developer.android.com/reference/kotlin/android/text/Layout#isFallbackLineSpacingEnabled())
- [android.text.StaticLayout.Builder#setUseLineSpacingFromFallbacks(boolean)](https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#setUseLineSpacingFromFallbacks(kotlin.Boolean))  

### setFontPaddingIncluded

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

```
fun setFontPaddingIncluded(includeFontPadding: Boolean): Layout.Builder
```

Set whether including extra padding into the first and the last line height. By setting true, the first line of the text and the last line of the text will have extra vertical space for avoiding clipping. The default value is`true`.

|                                                                            Parameters                                                                             ||
|----------------------|---------------------------------------------------------------------------------------------------------------------------------------------|
| `includeFontPadding` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html):true for including extra space into first and last line. |

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

**See Also**

- [android.text.Layout#isFontPaddingIncluded()](https://developer.android.com/reference/kotlin/android/text/Layout#isFontPaddingIncluded())
- [android.text.StaticLayout.Builder#setIncludePad(boolean)](https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#setIncludePad(kotlin.Boolean))  

### setHyphenationFrequency

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

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

Set the hyphenation frequency. The default value is[Layout.HYPHENATION_FREQUENCY_NONE](https://developer.android.com/reference/kotlin/android/text/Layout#HYPHENATION_FREQUENCY_NONE:kotlin.Int).

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

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

**See Also**

- [android.text.Layout#getHyphenationFrequency()](https://developer.android.com/reference/kotlin/android/text/Layout#getHyphenationFrequency())
- [android.text.StaticLayout.Builder#setHyphenationFrequency(int)](https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#setHyphenationFrequency(kotlin.Int))
- [android.text.Layout#HYPHENATION_FREQUENCY_NONE](https://developer.android.com/reference/kotlin/android/text/Layout#HYPHENATION_FREQUENCY_NONE:kotlin.Int)
- [android.text.Layout#HYPHENATION_FREQUENCY_NORMAL](https://developer.android.com/reference/kotlin/android/text/Layout#HYPHENATION_FREQUENCY_NORMAL:kotlin.Int)
- [android.text.Layout#HYPHENATION_FREQUENCY_FULL](https://developer.android.com/reference/kotlin/android/text/Layout#HYPHENATION_FREQUENCY_FULL:kotlin.Int)
- [android.text.Layout#HYPHENATION_FREQUENCY_NORMAL_FAST](https://developer.android.com/reference/kotlin/android/text/Layout#HYPHENATION_FREQUENCY_NORMAL_FAST:kotlin.Int)
- [android.text.Layout#HYPHENATION_FREQUENCY_FULL_FAST](https://developer.android.com/reference/kotlin/android/text/Layout#HYPHENATION_FREQUENCY_FULL_FAST:kotlin.Int)  

### setJustificationMode

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

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

Set justification mode. When justification mode is[Layout.JUSTIFICATION_MODE_INTER_WORD](https://developer.android.com/reference/kotlin/android/text/Layout#JUSTIFICATION_MODE_INTER_WORD:kotlin.Int), the word spacing on the given Paint passed to the constructor will be ignored. This behavior also affects spans which change the word spacing. The default value is[Layout.JUSTIFICATION_MODE_NONE](https://developer.android.com/reference/kotlin/android/text/Layout#JUSTIFICATION_MODE_NONE:kotlin.Int).

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

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

**See Also**

- [android.text.Layout#getJustificationMode()](https://developer.android.com/reference/kotlin/android/text/Layout#getJustificationMode())
- [android.text.StaticLayout.Builder#setJustificationMode(int)](https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#setJustificationMode(kotlin.Int))
- [android.text.Layout#JUSTIFICATION_MODE_NONE](https://developer.android.com/reference/kotlin/android/text/Layout#JUSTIFICATION_MODE_NONE:kotlin.Int)
- [android.text.Layout#JUSTIFICATION_MODE_INTER_WORD](https://developer.android.com/reference/kotlin/android/text/Layout#JUSTIFICATION_MODE_INTER_WORD:kotlin.Int)  

### setLeftIndents

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

```
fun setLeftIndents(leftIndents: IntArray?): Layout.Builder
```

Set visually left indents in pixels per lines. For the lines past the last element in the array, the last element repeats. Passing null for disabling indents. Note that even with the RTL layout, this method reserve spacing at the visually left of the line. The default value is`null`.

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

|                                                        Return                                                         ||
|-----------------------------------------------------------------------------------------------|------------------------|
| [Layout.Builder](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#) | this builder instance. |

**See Also**

- [android.text.Layout#getLeftIndents()](https://developer.android.com/reference/kotlin/android/text/Layout#getLeftIndents())
- [android.text.Layout#getRightIndents()](https://developer.android.com/reference/kotlin/android/text/Layout#getRightIndents())
- [android.text.Layout.Builder#setRightIndents(int[])](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#setRightIndents(kotlin.IntArray))
- [android.text.StaticLayout.Builder#setIndents(int[], int[])](https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#setIndents(kotlin.IntArray,%20kotlin.IntArray))  

### setLineBreakConfig

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

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

Set the line break configuration. The default value is a LinebreakConfig instance that has[LineBreakConfig.LINE_BREAK_STYLE_NONE](https://developer.android.com/reference/kotlin/android/graphics/text/LineBreakConfig.html#LINE_BREAK_STYLE_NONE:kotlin.Int)and[LineBreakConfig.LINE_BREAK_WORD_STYLE_NONE](https://developer.android.com/reference/kotlin/android/graphics/text/LineBreakConfig.html#LINE_BREAK_WORD_STYLE_NONE:kotlin.Int).

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

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

**See Also**

- [android.text.Layout#getLineBreakConfig()](https://developer.android.com/reference/kotlin/android/text/Layout#getLineBreakConfig())
- [android.text.StaticLayout.Builder#setLineBreakConfig(LineBreakConfig)](https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#setLineBreakConfig(android.graphics.text.LineBreakConfig))  

### setLineSpacingAmount

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

```
fun setLineSpacingAmount(amount: Float): Layout.Builder
```

Set the line spacing amount. The specified amount of pixels will be added to each line. The default value is`0`. The negative value is allowed for squeezing lines.

|                                                                Parameters                                                                ||
|----------|--------------------------------------------------------------------------------------------------------------------------------|
| `amount` | [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html):an amount of pixels to be added to line height. |

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

**See Also**

- [android.text.Layout#getLineSpacingAmount()](https://developer.android.com/reference/kotlin/android/text/Layout#getLineSpacingAmount())
- [android.text.Layout#getSpacingAdd()](https://developer.android.com/reference/kotlin/android/text/Layout#getSpacingAdd())
- [android.text.StaticLayout.Builder#setLineSpacing(float, float)](https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#setLineSpacing(kotlin.Float,%20kotlin.Float))  

### setLineSpacingMultiplier

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

```
fun setLineSpacingMultiplier(multiplier: Float): Layout.Builder
```

Set the line spacing multiplier. The specified value will be multiplied to each line. The default value is`1`.

|                                                                             Parameters                                                                              ||
|--------------|-------------------------------------------------------------------------------------------------------------------------------------------------------|
| `multiplier` | [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html):a multiplier to be applied to the line height Value is 0.0f or greater |

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

**See Also**

- [android.text.Layout#getLineSpacingMultiplier()](https://developer.android.com/reference/kotlin/android/text/Layout#getLineSpacingMultiplier())
- [android.text.Layout#getSpacingMultiplier()](https://developer.android.com/reference/kotlin/android/text/Layout#getSpacingMultiplier())
- [android.text.StaticLayout.Builder#setLineSpacing(float, float)](https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#setLineSpacing(kotlin.Float,%20kotlin.Float))  

### setMaxLines

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

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

Set the maximum number of lines. The default value 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 1 or greater |

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

**See Also**

- [android.text.Layout#getMaxLines()](https://developer.android.com/reference/kotlin/android/text/Layout#getMaxLines())
- [android.text.StaticLayout.Builder#setMaxLines(int)](https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#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?): Layout.Builder
```

Set the minimum font metrics used for line spacing.

`null`is the default value. If`null`is set or left it as default, the font metrics obtained by[Paint.getFontMetricsForLocale(Paint.FontMetrics)](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[Paint.ascent()](https://developer.android.com/reference/kotlin/android/graphics/Paint.html#ascent()), minimum value of[Paint.descent()](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[Paint.getFontMetricsForLocale(Paint.FontMetrics)](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[Paint.getFontMetricsForLocale(Paint.FontMetrics)](https://developer.android.com/reference/kotlin/android/graphics/Paint.html#getFontMetricsForLocale(android.graphics.Paint.FontMetrics)) |

**See Also**

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

### setRightIndents

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

```
fun setRightIndents(rightIndents: IntArray?): Layout.Builder
```

Set visually right indents in pixels per lines. For the lines past the last element in the array, the last element repeats. Passing null for disabling indents. Note that even with the RTL layout, this method reserve spacing at the visually right of the line. The default value is`null`.

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

|                                                        Return                                                         ||
|-----------------------------------------------------------------------------------------------|------------------------|
| [Layout.Builder](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#) | this builder instance. |

**See Also**

- [android.text.Layout#getLeftIndents()](https://developer.android.com/reference/kotlin/android/text/Layout#getLeftIndents())
- [android.text.Layout#getRightIndents()](https://developer.android.com/reference/kotlin/android/text/Layout#getRightIndents())
- [android.text.Layout.Builder#setLeftIndents(int[])](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#setLeftIndents(kotlin.IntArray))
- [android.text.StaticLayout.Builder#setIndents(int[], int[])](https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#setIndents(kotlin.IntArray,%20kotlin.IntArray))  

### setShiftDrawingOffsetForStartOverhang

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

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

Set true for shifting the drawing x offset for showing overhang at the start position. This flag is ignored if the[getUseBoundsForWidth()](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                                                           ||
|-----------------------------------------------------------------------------------------------|-----------------------------|
| [Layout.Builder](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#) | This value cannot be`null`. |

**See Also**

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

### setTextDirectionHeuristic

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

```
fun setTextDirectionHeuristic(textDirection: TextDirectionHeuristic): Layout.Builder
```

Set the text direction heuristics. The text direction heuristics is used to resolve text direction on the text. The default value is[TextDirectionHeuristics.FIRSTSTRONG_LTR](https://developer.android.com/reference/kotlin/android/text/TextDirectionHeuristics#FIRSTSTRONG_LTR:android.text.TextDirectionHeuristic)

|                                                                                      Parameters                                                                                       ||
|-----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `textDirection` | [TextDirectionHeuristic](https://developer.android.com/reference/kotlin/android/text/TextDirectionHeuristic):a text direction heuristic. This value cannot be`null`. |

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

**See Also**

- [android.text.TextDirectionHeuristics](https://developer.android.com/reference/kotlin/android/text/TextDirectionHeuristics)
- [android.text.Layout#getTextDirectionHeuristic()](https://developer.android.com/reference/kotlin/android/text/Layout#getTextDirectionHeuristic())
- [android.text.StaticLayout.Builder#setTextDirection(TextDirectionHeuristic)](https://developer.android.com/reference/kotlin/android/text/StaticLayout.Builder#setTextDirection(android.text.TextDirectionHeuristic))  

### setUseBoundsForWidth

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

```
fun setUseBoundsForWidth(useBoundsForWidth: Boolean): Layout.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                                                                      ||
|-----------------------------------------------------------------------------------------------|---------------------------------------------------|
| [Layout.Builder](https://developer.android.com/reference/kotlin/android/text/Layout.Builder#) | this builder instance This value cannot be`null`. |

**See Also**

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