LineBreak
expect value class LineBreak private constructor(internal val mask: Int)
When soft wrap is enabled and the width of the text exceeds the width of its container, line breaks are inserted in the text to split it over multiple lines.
There are a number of parameters that affect how the line breaks are inserted. For example, the breaking algorithm can be changed to one with improved readability at the cost of speed. Another example is the strictness, which in some languages determines which symbols can appear at the start of a line.
LineBreak
represents a configuration for line breaking, offering several presets for different
use cases: Simple
, Heading
, Paragraph
.
For further customization, each platform has its own parameters. An example on Android:
Companion Object
Properties
val Simple: LineBreak
Basic, fast line breaking. Ideal for text input fields, as it will cause minimal text reflow when editing.
val Heading: LineBreak
Looser breaking rules, suitable for short text such as titles or narrow newspaper
columns. For longer lines of text, use Paragraph
for improved readability.
val Paragraph: LineBreak
Slower, higher quality line breaking for improved readability. Suitable for larger amounts of text.
val Unspecified: LineBreak
This represents an unset value, a usual replacement for "null" when a primitive value is desired.
actual value class LineBreak internal constructor(internal val mask: Int)
When soft wrap is enabled and the width of the text exceeds the width of its container, line breaks are inserted in the text to split it over multiple lines.
There are a number of parameters that affect how the line breaks are inserted. For example, the breaking algorithm can be changed to one with improved readability at the cost of speed. Another example is the strictness, which in some languages determines which symbols can appear at the start of a line.
This represents a configuration for line breaking on Android, describing Strategy
,
Strictness
, and WordBreak
.
Secondary Constructors
constructor(
strategy: Strategy,
strictness: Strictness,
wordBreak: WordBreak,
) : this(packBytes(strategy.value, strictness.value, wordBreak.value))
This represents a configuration for line breaking on Android, describing Strategy
,
Strictness
, and WordBreak
.
Parameters
strategy | defines the algorithm that inserts line breaks |
strictness | defines the line breaking rules |
wordBreak | defines how words are broken |
Properties
val strategy: Strategy
val strictness: Strictness
val wordBreak: WordBreak
Functions
fun copy(
strategy: Strategy = this.strategy,
strictness: Strictness = this.strictness,
wordBreak: WordBreak = this.wordBreak,
): LineBreak
Companion Object
Properties
actual val Simple: LineBreak
The greedy, fast line breaking algorithm. Ideal for text that updates often, such as a text editor, as the text will reflow minimally.
+---------+ This is | an | example | text. | 今日は自 | 由が丘で | 焼き鳥を | 食べま | す。 | +---------+
actual val Heading: LineBreak
Balanced line lengths, hyphenation, and phrase-based breaking. Suitable for short text such as titles or narrow newspaper columns.
+---------+ This | is an | example | text. | 今日は | 自由が丘 | で焼き鳥 | を食べ | ます。 | +---------+
actual val Paragraph: LineBreak
Slower, higher quality line breaking for improved readability. Suitable for larger amounts of text.
+---------+ This | is an | example | text. | 今日は自 | 由が丘で | 焼き鳥を | 食べま | す。 | +---------+
actual val Unspecified: LineBreak
This represents an unset value, a usual replacement for "null" when a primitive value is desired.