# LineBreaker.Builder

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

# Builder

*** ** * ** ***

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

```
class Builder
```

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

Helper class for creating a[LineBreaker](https://developer.android.com/reference/kotlin/android/graphics/text/LineBreaker).

## Summary

|                                                     Public constructors                                                     ||
|--------------------------------------------------------------------------------------------------------------------------|---|
| [Builder](https://developer.android.com/reference/kotlin/android/graphics/text/LineBreaker.Builder#Builder())`()` <br /> |

|                                                                                                                                                                                                                            Public methods                                                                                                                                                                                                                             ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [LineBreaker](https://developer.android.com/reference/kotlin/android/graphics/text/LineBreaker)                  | [build](https://developer.android.com/reference/kotlin/android/graphics/text/LineBreaker.Builder#build())`()` Build a new LineBreaker with given parameters.                                                                                                                                                                                        |
| [LineBreaker.Builder](https://developer.android.com/reference/kotlin/android/graphics/text/LineBreaker.Builder#) | [setBreakStrategy](https://developer.android.com/reference/kotlin/android/graphics/text/LineBreaker.Builder#setBreakStrategy(kotlin.Int))`(`breakStrategy:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Set break strategy.                                                                                      |
| [LineBreaker.Builder](https://developer.android.com/reference/kotlin/android/graphics/text/LineBreaker.Builder#) | [setHyphenationFrequency](https://developer.android.com/reference/kotlin/android/graphics/text/LineBreaker.Builder#setHyphenationFrequency(kotlin.Int))`(`hyphenationFrequency:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Set hyphenation frequency.                                                          |
| [LineBreaker.Builder](https://developer.android.com/reference/kotlin/android/graphics/text/LineBreaker.Builder#) | [setIndents](https://developer.android.com/reference/kotlin/android/graphics/text/LineBreaker.Builder#setIndents(kotlin.IntArray))`(`indents:` `[IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html)?`)` Set indents.                                                                                              |
| [LineBreaker.Builder](https://developer.android.com/reference/kotlin/android/graphics/text/LineBreaker.Builder#) | [setJustificationMode](https://developer.android.com/reference/kotlin/android/graphics/text/LineBreaker.Builder#setJustificationMode(kotlin.Int))`(`justificationMode:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Set whether the text is justified.                                                           |
| [LineBreaker.Builder](https://developer.android.com/reference/kotlin/android/graphics/text/LineBreaker.Builder#) | [setUseBoundsForWidth](https://developer.android.com/reference/kotlin/android/graphics/text/LineBreaker.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. |

## Public constructors

### Builder

```
Builder()
```

## Public methods

### build

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

```
fun build(): LineBreaker
```

Build a new LineBreaker with given parameters. You can reuse the Builder instance even after calling this method.

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

### setBreakStrategy

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

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

Set break strategy. You can change the line breaking behavior by setting break strategy. The default value is[BREAK_STRATEGY_SIMPLE](https://developer.android.com/reference/kotlin/android/graphics/text/LineBreaker#BREAK_STRATEGY_SIMPLE:kotlin.Int).

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

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

### setHyphenationFrequency

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

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

Set hyphenation frequency. You can change the amount of automatic hyphenation used. The default value is[HYPHENATION_FREQUENCY_NONE](https://developer.android.com/reference/kotlin/android/graphics/text/LineBreaker#HYPHENATION_FREQUENCY_NONE:kotlin.Int).

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

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

### setIndents

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

```
fun setIndents(indents: IntArray?): LineBreaker.Builder
```

Set indents. The supplied array provides the total amount of indentation per line, in pixel. This amount is the sum of both left and right indentations. For lines past the last element in the array, the indentation amount of the last element is used.

|                                                         Parameters                                                         ||
|-----------|-----------------------------------------------------------------------------------------------------------------|
| `indents` | [IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html)?:This value may be`null`. |

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

### setJustificationMode

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

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

Set whether the text is justified. By setting[JUSTIFICATION_MODE_INTER_WORD](https://developer.android.com/reference/kotlin/android/graphics/text/LineBreaker#JUSTIFICATION_MODE_INTER_WORD:kotlin.Int), the line breaker will change the internal parameters for justification. The default value is[JUSTIFICATION_MODE_NONE](https://developer.android.com/reference/kotlin/android/graphics/text/LineBreaker#JUSTIFICATION_MODE_NONE:kotlin.Int)

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

|                                                                    Return                                                                     ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [LineBreaker.Builder](https://developer.android.com/reference/kotlin/android/graphics/text/LineBreaker.Builder#) | 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): LineBreaker.Builder
```

Set true for using width of bounding box as a source of automatic line breaking. If this value is false, the automatic line breaking uses total amount of advances as text widths. By setting true, it uses joined all glyph bound's width as a width of the text. 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 line breaker will break line based on bounding box, so clipping can be prevented.

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

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

**See Also**

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