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

# LineBreaker.Builder

*** ** * ** ***


`
public
static
final

class
LineBreaker.Builder
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

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

<br />

*** ** * ** ***

Helper class for creating a `https://developer.android.com/reference/android/graphics/text/LineBreaker`.

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/graphics/text/LineBreaker.Builder#Builder()() ` |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/graphics/text/LineBreaker` | ` https://developer.android.com/reference/android/graphics/text/LineBreaker.Builder#build()() ` Build a new LineBreaker with given parameters. |
| ` https://developer.android.com/reference/android/graphics/text/LineBreaker.Builder` | ` https://developer.android.com/reference/android/graphics/text/LineBreaker.Builder#setBreakStrategy(int)(int breakStrategy) ` Set break strategy. |
| ` https://developer.android.com/reference/android/graphics/text/LineBreaker.Builder` | ` https://developer.android.com/reference/android/graphics/text/LineBreaker.Builder#setHyphenationFrequency(int)(int hyphenationFrequency) ` Set hyphenation frequency. |
| ` https://developer.android.com/reference/android/graphics/text/LineBreaker.Builder` | ` https://developer.android.com/reference/android/graphics/text/LineBreaker.Builder#setIndents(int[])(int[] indents) ` Set indents. |
| ` https://developer.android.com/reference/android/graphics/text/LineBreaker.Builder` | ` https://developer.android.com/reference/android/graphics/text/LineBreaker.Builder#setJustificationMode(int)(int justificationMode) ` Set whether the text is justified. |
| ` https://developer.android.com/reference/android/graphics/text/LineBreaker.Builder` | ` https://developer.android.com/reference/android/graphics/text/LineBreaker.Builder#setUseBoundsForWidth(boolean)(boolean useBoundsForWidth) ` Set true for using width of bounding box as a source of automatic line breaking. |

| ### 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 constructors

### Builder

```
public Builder ()
```

<br />

<br />

## Public methods

### build

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

```
public LineBreaker build ()
```

Build a new LineBreaker with given parameters.

You can reuse the Builder instance even after calling this method.

<br />

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

### setBreakStrategy

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

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

Set break strategy.

You can change the line breaking behavior by setting break strategy. The default value is
`https://developer.android.com/reference/android/graphics/text/LineBreaker#BREAK_STRATEGY_SIMPLE`.

<br />

| Parameters ||
|---|---|
| `breakStrategy` | `int`: 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/graphics/text/LineBreaker.Builder` | This value cannot be `null`. <br /> |

### setHyphenationFrequency

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

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

Set hyphenation frequency.

You can change the amount of automatic hyphenation used. The default value is
`https://developer.android.com/reference/android/graphics/text/LineBreaker#HYPHENATION_FREQUENCY_NONE`.

<br />

| Parameters ||
|---|---|
| `hyphenationFrequency` | `int`: Value is one of the following: - `https://developer.android.com/reference/android/graphics/text/LineBreaker#HYPHENATION_FREQUENCY_NORMAL` - `https://developer.android.com/reference/android/graphics/text/LineBreaker#HYPHENATION_FREQUENCY_FULL` - `https://developer.android.com/reference/android/graphics/text/LineBreaker#HYPHENATION_FREQUENCY_NONE` |

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

### setIndents

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

```
public LineBreaker.Builder setIndents (int[] indents)
```

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.

<br />

| Parameters ||
|---|---|
| `indents` | `int`: This value may be `null`. <br /> |

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

### setJustificationMode

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

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

Set whether the text is justified.

By setting `https://developer.android.com/reference/android/graphics/text/LineBreaker#JUSTIFICATION_MODE_INTER_WORD`, the line breaker will change the
internal parameters for justification.
The default value is `https://developer.android.com/reference/android/graphics/text/LineBreaker#JUSTIFICATION_MODE_NONE`

<br />

| Parameters ||
|---|---|
| `justificationMode` | `int`: 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/graphics/text/LineBreaker.Builder` | This value cannot be `null`. <br /> |

### setUseBoundsForWidth

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

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

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.

<br />

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

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/text/LineBreaker.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/StaticLayout.Builder#setUseBoundsForWidth(boolean)`