LineBreaker.Builder

public static final class LineBreaker.Builder
extends Object

java.lang.Object
   ↳ android.graphics.text.LineBreaker.Builder


Helper class for creating a LineBreaker.

Summary

Public constructors

Builder()

Public methods

LineBreaker build()

Build a new LineBreaker with given parameters.

LineBreaker.Builder setBreakStrategy(int breakStrategy)

Set break strategy.

LineBreaker.Builder setHyphenationFrequency(int hyphenationFrequency)

Set hyphenation frequency.

LineBreaker.Builder setIndents(int[] indents)

Set indents.

LineBreaker.Builder setJustificationMode(int justificationMode)

Set whether the text is justified.

Inherited methods

Public constructors

Builder

public Builder ()

Public methods

build

Added in API level 29
public LineBreaker build ()

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

Returns
LineBreaker This value cannot be null.

setBreakStrategy

Added in API level 29
public LineBreaker.Builder setBreakStrategy (int breakStrategy)

Set break strategy. You can change the line breaking behavior by setting break strategy. The default value is LineBreaker.BREAK_STRATEGY_SIMPLE.

Parameters
breakStrategy int: Value is LineBreaker.BREAK_STRATEGY_SIMPLE, LineBreaker.BREAK_STRATEGY_HIGH_QUALITY, or LineBreaker.BREAK_STRATEGY_BALANCED

Returns
LineBreaker.Builder This value cannot be null.

setHyphenationFrequency

Added in API level 29
public LineBreaker.Builder setHyphenationFrequency (int hyphenationFrequency)

Set hyphenation frequency. You can change the amount of automatic hyphenation used. The default value is LineBreaker.HYPHENATION_FREQUENCY_NONE.

Parameters
hyphenationFrequency int: Value is LineBreaker.HYPHENATION_FREQUENCY_NORMAL, LineBreaker.HYPHENATION_FREQUENCY_FULL, or LineBreaker.HYPHENATION_FREQUENCY_NONE

Returns
LineBreaker.Builder This value cannot be null.

setIndents

Added in API level 29
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.

Parameters
indents int: This value may be null.

Returns
LineBreaker.Builder This value cannot be null.

setJustificationMode

Added in API level 29
public LineBreaker.Builder setJustificationMode (int justificationMode)

Set whether the text is justified. By setting LineBreaker.JUSTIFICATION_MODE_INTER_WORD, the line breaker will change the internal parameters for justification. The default value is LineBreaker.JUSTIFICATION_MODE_NONE

Parameters
justificationMode int: Value is LineBreaker.JUSTIFICATION_MODE_NONE, or LineBreaker.JUSTIFICATION_MODE_INTER_WORD

Returns
LineBreaker.Builder This value cannot be null.