Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Methods](https://developer.android.com/reference/android/text/StaticLayout.Builder#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/text/StaticLayout.Builder#inhmethods)

# StaticLayout.Builder

*** ** * ** ***

` public static final class StaticLayout.Builder `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.text.StaticLayout.Builder |

<br />

*** ** * ** ***

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/android/text/StaticLayout.Builder#obtain(java.lang.CharSequence,%20int,%20int,%20android.text.TextPaint,%20int)` with the required arguments (text, paint, and width), then call setters for optional parameters, and finally `https://developer.android.com/reference/android/text/StaticLayout.Builder#build()` to build the StaticLayout object. Parameters not explicitly set will get default values.

## Summary

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/text/StaticLayout` | ` https://developer.android.com/reference/android/text/StaticLayout.Builder#build()() ` Build the `https://developer.android.com/reference/android/text/StaticLayout` after options have been set. |
| ` static https://developer.android.com/reference/android/text/StaticLayout.Builder` | ` https://developer.android.com/reference/android/text/StaticLayout.Builder#obtain(java.lang.CharSequence,%20int,%20int,%20android.text.TextPaint,%20int)(https://developer.android.com/reference/java/lang/CharSequence source, int start, int end, https://developer.android.com/reference/android/text/TextPaint paint, int width) ` Obtain a builder for constructing StaticLayout objects. |
| ` https://developer.android.com/reference/android/text/StaticLayout.Builder` | ` https://developer.android.com/reference/android/text/StaticLayout.Builder#setAlignment(android.text.Layout.Alignment)(https://developer.android.com/reference/android/text/Layout.Alignment alignment) ` Set the alignment. |
| ` https://developer.android.com/reference/android/text/StaticLayout.Builder` | ` https://developer.android.com/reference/android/text/StaticLayout.Builder#setBreakStrategy(int)(int breakStrategy) ` Set break strategy, useful for selecting high quality or balanced paragraph layout options. |
| ` https://developer.android.com/reference/android/text/StaticLayout.Builder` | ` https://developer.android.com/reference/android/text/StaticLayout.Builder#setEllipsize(android.text.TextUtils.TruncateAt)(https://developer.android.com/reference/android/text/TextUtils.TruncateAt ellipsize) ` Set ellipsizing on the layout. |
| ` https://developer.android.com/reference/android/text/StaticLayout.Builder` | ` https://developer.android.com/reference/android/text/StaticLayout.Builder#setEllipsizedWidth(int)(int ellipsizedWidth) ` Set the width as used for ellipsizing purposes, if it differs from the normal layout width. |
| ` https://developer.android.com/reference/android/text/StaticLayout.Builder` | ` https://developer.android.com/reference/android/text/StaticLayout.Builder#setHyphenationFrequency(int)(int hyphenationFrequency) ` Set hyphenation frequency, to control the amount of automatic hyphenation used. |
| ` https://developer.android.com/reference/android/text/StaticLayout.Builder` | ` https://developer.android.com/reference/android/text/StaticLayout.Builder#setIncludePad(boolean)(boolean includePad) ` 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). |
| ` https://developer.android.com/reference/android/text/StaticLayout.Builder` | ` https://developer.android.com/reference/android/text/StaticLayout.Builder#setIndents(int[],%20int[])(int[] leftIndents, int[] rightIndents) ` Set indents. |
| ` https://developer.android.com/reference/android/text/StaticLayout.Builder` | ` https://developer.android.com/reference/android/text/StaticLayout.Builder#setJustificationMode(int)(int justificationMode) ` Set paragraph justification mode. |
| ` https://developer.android.com/reference/android/text/StaticLayout.Builder` | ` https://developer.android.com/reference/android/text/StaticLayout.Builder#setLineBreakConfig(android.graphics.text.LineBreakConfig)(https://developer.android.com/reference/android/graphics/text/LineBreakConfig lineBreakConfig) ` Set the line break configuration. |
| ` https://developer.android.com/reference/android/text/StaticLayout.Builder` | ` https://developer.android.com/reference/android/text/StaticLayout.Builder#setLineSpacing(float,%20float)(float spacingAdd, float spacingMult) ` Set line spacing parameters. |
| ` https://developer.android.com/reference/android/text/StaticLayout.Builder` | ` https://developer.android.com/reference/android/text/StaticLayout.Builder#setMaxLines(int)(int maxLines) ` Set maximum number of lines. |
| ` https://developer.android.com/reference/android/text/StaticLayout.Builder` | ` https://developer.android.com/reference/android/text/StaticLayout.Builder#setMinimumFontMetrics(android.graphics.Paint.FontMetrics)(https://developer.android.com/reference/android/graphics/Paint.FontMetrics minimumFontMetrics) ` Set the minimum font metrics used for line spacing. |
| ` https://developer.android.com/reference/android/text/StaticLayout.Builder` | ` https://developer.android.com/reference/android/text/StaticLayout.Builder#setShiftDrawingOffsetForStartOverhang(boolean)(boolean shiftDrawingOffsetForStartOverhang) ` Set true for shifting the drawing x offset for showing overhang at the start position. |
| ` https://developer.android.com/reference/android/text/StaticLayout.Builder` | ` https://developer.android.com/reference/android/text/StaticLayout.Builder#setText(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence source) ` |
| ` https://developer.android.com/reference/android/text/StaticLayout.Builder` | ` https://developer.android.com/reference/android/text/StaticLayout.Builder#setTextDirection(android.text.TextDirectionHeuristic)(https://developer.android.com/reference/android/text/TextDirectionHeuristic textDir) ` Set the text direction heuristic. |
| ` https://developer.android.com/reference/android/text/StaticLayout.Builder` | ` https://developer.android.com/reference/android/text/StaticLayout.Builder#setUseBoundsForWidth(boolean)(boolean useBoundsForWidth) ` Set true for using width of bounding box as a source of automatic line breaking and drawing. |
| ` https://developer.android.com/reference/android/text/StaticLayout.Builder` | ` https://developer.android.com/reference/android/text/StaticLayout.Builder#setUseLineSpacingFromFallbacks(boolean)(boolean useLineSpacingFromFallbacks) ` 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). |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Public methods

### build

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

```
public StaticLayout build ()
```

Build the `https://developer.android.com/reference/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.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/text/StaticLayout` | the newly constructed `https://developer.android.com/reference/android/text/StaticLayout` object. This value cannot be `null`. <br /> |

### obtain

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

```
public static StaticLayout.Builder obtain (CharSequence source, 
                int start, 
                int end, 
                TextPaint paint, 
                int width)
```

Obtain a builder for constructing StaticLayout objects.

<br />

| Parameters ||
|---|---|
| `source` | `CharSequence`: The text to be laid out, optionally with spans. This value cannot be `null`. <br /> |
| `start` | `int`: The index of the start of the text. Value is 0 or greater <br /> |
| `end` | `int`: The index + 1 of the end of the text. Value is 0 or greater <br /> |
| `paint` | `TextPaint`: The base paint used for layout. This value cannot be `null`. <br /> |
| `width` | `int`: The width in pixels. Value is 0 or greater <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/text/StaticLayout.Builder` | a builder object used for constructing the StaticLayout. This value cannot be `null`. <br /> |

### setAlignment

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

```
public StaticLayout.Builder setAlignment (Layout.Alignment alignment)
```

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

<br />

| Parameters ||
|---|---|
| `alignment` | `Layout.Alignment`: Alignment for the resulting `https://developer.android.com/reference/android/text/StaticLayout` This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/text/StaticLayout.Builder` | this builder, useful for chaining. This value cannot be `null`. <br /> |

### setBreakStrategy

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

```
public StaticLayout.Builder setBreakStrategy (int breakStrategy)
```

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

<br />

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

<br />

<br />

| Parameters ||
|---|---|
| `breakStrategy` | `int`: break strategy for paragraph layout. Value is one of the following: - `https://developer.android.com/reference/android/graphics/text/LineBreaker#BREAK_STRATEGY_SIMPLE` - `https://developer.android.com/reference/android/graphics/text/LineBreaker#BREAK_STRATEGY_HIGH_QUALITY` - `https://developer.android.com/reference/android/graphics/text/LineBreaker#BREAK_STRATEGY_BALANCED` |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/text/StaticLayout.Builder` | this builder, useful for chaining. This value cannot be `null`. <br /> |

**See also:**

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

### setEllipsize

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

```
public StaticLayout.Builder setEllipsize (TextUtils.TruncateAt ellipsize)
```

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/android/text/TextUtils.TruncateAt#END` or `https://developer.android.com/reference/android/text/TextUtils.TruncateAt#MARQUEE`, to be ellipsized instead of broken. The default is `null`, indicating no ellipsis is to be applied.

<br />

| Parameters ||
|---|---|
| `ellipsize` | `TextUtils.TruncateAt`: type of ellipsis behavior. This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/text/StaticLayout.Builder` | this builder, useful for chaining <br /> |

**See also:**

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

### setEllipsizedWidth

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

```
public StaticLayout.Builder setEllipsizedWidth (int ellipsizedWidth)
```

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/android/text/StaticLayout.Builder#obtain(java.lang.CharSequence,%20int,%20int,%20android.text.TextPaint,%20int)`.

<br />

| Parameters ||
|---|---|
| `ellipsizedWidth` | `int`: width used for ellipsizing, in pixels. Value is 0 or greater <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/text/StaticLayout.Builder` | this builder, useful for chaining. This value cannot be `null`. <br /> |

**See also:**

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

### setHyphenationFrequency

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

```
public StaticLayout.Builder setHyphenationFrequency (int hyphenationFrequency)
```

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

<br />

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

<br />

<br />

| Parameters ||
|---|---|
| `hyphenationFrequency` | `int`: hyphenation frequency for the paragraph. Value is one of the following: - `https://developer.android.com/reference/android/text/Layout#HYPHENATION_FREQUENCY_NORMAL` - `https://developer.android.com/reference/android/text/Layout#HYPHENATION_FREQUENCY_NORMAL_FAST` - `https://developer.android.com/reference/android/text/Layout#HYPHENATION_FREQUENCY_FULL` - `https://developer.android.com/reference/android/text/Layout#HYPHENATION_FREQUENCY_FULL_FAST` - `https://developer.android.com/reference/android/text/Layout#HYPHENATION_FREQUENCY_NONE` |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/text/StaticLayout.Builder` | this builder, useful for chaining. This value cannot be `null`. <br /> |

**See also:**

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

### setIncludePad

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

```
public StaticLayout.Builder setIncludePad (boolean includePad)
```

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

<br />

| Parameters ||
|---|---|
| `includePad` | `boolean`: whether to include padding <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/text/StaticLayout.Builder` | this builder, useful for chaining. This value cannot be `null`. <br /> |

**See also:**

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

### setIndents

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

```
public StaticLayout.Builder setIndents (int[] leftIndents, 
                int[] rightIndents)
```

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.

<br />

| Parameters ||
|---|---|
| `leftIndents` | `int`: array of indent values for left margin, in pixels. This value may be `null`. <br /> |
| `rightIndents` | `int`: array of indent values for right margin, in pixels. This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/text/StaticLayout.Builder` | this builder, useful for chaining. This value cannot be `null`. <br /> |

### setJustificationMode

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

```
public StaticLayout.Builder setJustificationMode (int justificationMode)
```

Set paragraph justification mode. The default value is `https://developer.android.com/reference/android/text/Layout#JUSTIFICATION_MODE_NONE`. 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/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/android/graphics/Paint` will be ignored. This behavior also affects Spans which change the wordSpacing.

<br />

| Parameters ||
|---|---|
| `justificationMode` | `int`: justification mode for the paragraph. Value is one of the following: - `https://developer.android.com/reference/android/graphics/text/LineBreaker#JUSTIFICATION_MODE_NONE` - `https://developer.android.com/reference/android/graphics/text/LineBreaker#JUSTIFICATION_MODE_INTER_WORD` - `https://developer.android.com/reference/android/graphics/text/LineBreaker#JUSTIFICATION_MODE_INTER_CHARACTER` |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/text/StaticLayout.Builder` | this builder, useful for chaining. This value cannot be `null`. <br /> |

**See also:**

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

### setLineBreakConfig

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

```
public StaticLayout.Builder setLineBreakConfig (LineBreakConfig lineBreakConfig)
```

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/android/graphics/text/LineBreakConfig#LINE_BREAK_STYLE_NONE`

<br />

| Parameters ||
|---|---|
| `lineBreakConfig` | `LineBreakConfig`: the line break configuration for text wrapping. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/text/StaticLayout.Builder` | this builder, useful for chaining. This value cannot be `null`. <br /> |

**See also:**

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

### setLineSpacing

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

```
public StaticLayout.Builder setLineSpacing (float spacingAdd, 
                float spacingMult)
```

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

<br />

| Parameters ||
|---|---|
| `spacingAdd` | `float`: the amount of line spacing addition <br /> |
| `spacingMult` | `float`: the line spacing multiplier. Value is 0.0f or greater <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/text/StaticLayout.Builder` | this builder, useful for chaining. This value cannot be `null`. <br /> |

**See also:**

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

### setMaxLines

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

```
public StaticLayout.Builder setMaxLines (int maxLines)
```

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.

<br />

| Parameters ||
|---|---|
| `maxLines` | `int`: maximum number of lines in the layout. Value is 0 or greater <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/text/StaticLayout.Builder` | this builder, useful for chaining. This value cannot be `null`. <br /> |

**See also:**

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

### setMinimumFontMetrics

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

```
public StaticLayout.Builder setMinimumFontMetrics (Paint.FontMetrics minimumFontMetrics)
```

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/android/graphics/Paint#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/android/graphics/Paint#ascent()`, minimum value of `https://developer.android.com/reference/android/graphics/Paint#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/android/graphics/Paint#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.

<br />

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

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/text/StaticLayout.Builder` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/widget/TextView#setMinimumFontMetrics(android.graphics.Paint.FontMetrics)`
- `https://developer.android.com/reference/android/widget/TextView#getMinimumFontMetrics()`
- `https://developer.android.com/reference/android/text/Layout#getMinimumFontMetrics()`
- `https://developer.android.com/reference/android/text/Layout.Builder#setMinimumFontMetrics(android.graphics.Paint.FontMetrics)`
- `https://developer.android.com/reference/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#ApiLevels)

```
public StaticLayout.Builder setShiftDrawingOffsetForStartOverhang (boolean shiftDrawingOffsetForStartOverhang)
```

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

<br />

| Parameters ||
|---|---|
| `shiftDrawingOffsetForStartOverhang` | `boolean`: true for shifting the drawing offset for showing the stroke that is in the region where the x coordinate is negative. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/text/StaticLayout.Builder` | This value cannot be `null`. <br /> |

**See also:**

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

### setText

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

```
public StaticLayout.Builder setText (CharSequence source)
```

<br />

<br />

| Parameters ||
|---|---|
| `source` | `CharSequence` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/text/StaticLayout.Builder` | <br /> |

### setTextDirection

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

```
public StaticLayout.Builder setTextDirection (TextDirectionHeuristic textDir)
```

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/android/text/TextDirectionHeuristics#FIRSTSTRONG_LTR`.

<br />

| Parameters ||
|---|---|
| `textDir` | `TextDirectionHeuristic`: text direction heuristic for resolving bidi behavior. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/text/StaticLayout.Builder` | this builder, useful for chaining. This value cannot be `null`. <br /> |

### setUseBoundsForWidth

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

```
public StaticLayout.Builder setUseBoundsForWidth (boolean useBoundsForWidth)
```

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.

<br />

| Parameters ||
|---|---|
| `useBoundsForWidth` | `boolean`: True for using bounding box, false for advances. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/text/StaticLayout.Builder` | this builder instance. This value cannot be `null`. <br /> |

**See also:**

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

### setUseLineSpacingFromFallbacks

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

```
public StaticLayout.Builder setUseLineSpacingFromFallbacks (boolean useLineSpacingFromFallbacks)
```

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.

<br />

| Parameters ||
|---|---|
| `useLineSpacingFromFallbacks` | `boolean`: whether to expand linespacing based on fallback fonts <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/text/StaticLayout.Builder` | this builder, useful for chaining. This value cannot be `null`. <br /> |