Builder
class Builder
kotlin.Any | |
↳ | android.graphics.text.LineBreakConfig.Builder |
A builder for creating a LineBreakConfig
instance.
Summary
Public constructors | |
---|---|
Builder() Builder constructor. |
Public methods | |
---|---|
LineBreakConfig |
build() Builds a |
LineBreakConfig.Builder |
merge(config: LineBreakConfig) Merges line break config with other config Update the internal configurations with passed |
LineBreakConfig.Builder |
setHyphenation(hyphenation: Int) Sets the hyphenation preference Note: Even if the |
LineBreakConfig.Builder |
setLineBreakStyle(lineBreakStyle: Int) Sets the line-break style. |
LineBreakConfig.Builder |
setLineBreakWordStyle(lineBreakWordStyle: Int) Sets the line-break word style. |
Public constructors
Public methods
build
fun build(): LineBreakConfig
Builds a LineBreakConfig
instance. This method can be called multiple times for generating multiple LineBreakConfig
instances.
Return | |
---|---|
LineBreakConfig |
The LineBreakConfig instance. This value cannot be null . |
merge
fun merge(config: LineBreakConfig): LineBreakConfig.Builder
Merges line break config with other config Update the internal configurations with passed config
. If the config values of passed config
are unspecified, the original config values are kept. For example, the following code passes config
that has LINE_BREAK_STYLE_UNSPECIFIED
. This code generates LineBreakConfig
that has line break config LINE_BREAK_STYLE_STRICT
.
val override = LineBreakConfig.Builder() .setLineBreakWordStyle(LineBreakConfig.LINE_BREAK_WORD_STYLE_PHRASE) .build(); // UNSPECIFIED if no setLineBreakStyle is called. val config = LineBreakConfig.Builder() .setLineBreakStyle(LineBreakConfig.LINE_BREAK_STYLE_STRICT) .merge(override) .build() // Here, config has LINE_BREAK_STYLE_STRICT of line break config and // LINE_BREAK_WORD_STYLE_PHRASE of line break word style.
Parameters | |
---|---|
config |
LineBreakConfig: an override line break config This value cannot be null . |
Return | |
---|---|
LineBreakConfig.Builder |
This Builder . This value cannot be null . |
setHyphenation
fun setHyphenation(hyphenation: Int): LineBreakConfig.Builder
Sets the hyphenation preference Note: Even if the LineBreakConfig.HYPHENATION_ENABLED
is specified, the hyphenation will not be performed if the android.widget.TextView
or underlying android.text.StaticLayout
, LineBreaker
are configured with LineBreaker.HYPHENATION_FREQUENCY_NONE
. Note: Even if the hyphenation is enabled with a line break strategy LineBreaker.BREAK_STRATEGY_SIMPLE
, the hyphenation will not be performed unless a single word cannot meet width constraints.
Parameters | |
---|---|
hyphenation |
Int: The hyphenation preference. Value is android.graphics.text.LineBreakConfig#HYPHENATION_UNSPECIFIED , android.graphics.text.LineBreakConfig#HYPHENATION_ENABLED , or android.graphics.text.LineBreakConfig#HYPHENATION_DISABLED |
Return | |
---|---|
LineBreakConfig.Builder |
This Builder . This value cannot be null . |
setLineBreakStyle
fun setLineBreakStyle(lineBreakStyle: Int): LineBreakConfig.Builder
Sets the line-break style.
Return | |
---|---|
LineBreakConfig.Builder |
This Builder . This value cannot be null . |
See Also
setLineBreakWordStyle
fun setLineBreakWordStyle(lineBreakWordStyle: Int): LineBreakConfig.Builder
Sets the line-break word style.
Parameters | |
---|---|
lineBreakWordStyle |
Int: The new line-break word style. Value is android.graphics.text.LineBreakConfig#LINE_BREAK_WORD_STYLE_NONE , android.graphics.text.LineBreakConfig#LINE_BREAK_WORD_STYLE_PHRASE , android.graphics.text.LineBreakConfig#LINE_BREAK_WORD_STYLE_UNSPECIFIED , or android.graphics.text.LineBreakConfig#LINE_BREAK_WORD_STYLE_AUTO |
Return | |
---|---|
LineBreakConfig.Builder |
This Builder . This value cannot be null . |
See Also