Builder
class Builder
kotlin.Any | |
↳ | 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(breakStrategy: Int) Set break strategy. |
LineBreaker.Builder |
setHyphenationFrequency(hyphenationFrequency: Int) Set hyphenation frequency. |
LineBreaker.Builder |
setIndents(indents: IntArray?) Set indents. |
LineBreaker.Builder |
setJustificationMode(justificationMode: Int) Set whether the text is justified. |
LineBreaker.Builder |
setUseBoundsForWidth(useBoundsForWidth: Boolean) Set true for using width of bounding box as a source of automatic line breaking. |
Public constructors
Builder
Builder()
Public methods
build
fun build(): LineBreaker
Build a new LineBreaker with given parameters. You can reuse the Builder instance even after calling this method.
Return | |
---|---|
LineBreaker |
This value cannot be null . |
setBreakStrategy
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
.
Return | |
---|---|
LineBreaker.Builder |
This value cannot be null . |
setHyphenationFrequency
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
.
Parameters | |
---|---|
hyphenationFrequency |
Int: Value is android.graphics.text.LineBreaker#HYPHENATION_FREQUENCY_NORMAL , android.graphics.text.LineBreaker#HYPHENATION_FREQUENCY_FULL , or android.graphics.text.LineBreaker#HYPHENATION_FREQUENCY_NONE |
Return | |
---|---|
LineBreaker.Builder |
This value cannot be null . |
setIndents
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?: This value may be null . |
Return | |
---|---|
LineBreaker.Builder |
This value cannot be null . |
setJustificationMode
fun setJustificationMode(justificationMode: Int): LineBreaker.Builder
Set whether the text is justified. By setting JUSTIFICATION_MODE_INTER_WORD
, the line breaker will change the internal parameters for justification. The default value is JUSTIFICATION_MODE_NONE
Return | |
---|---|
LineBreaker.Builder |
This value cannot be null . |
setUseBoundsForWidth
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: True for using bounding box, false for advances. |
Return | |
---|---|
LineBreaker.Builder |
this builder instance This value cannot be null . |