Added in 1.11.0-rc01
expect value class LineBreak
@Suppress("KmpVisibilityMismatch")
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
Added in 1.11.0-rc01
val Simple: LineBreak
Basic, fast line breaking. Ideal for text input fields, as it will cause minimal text reflow when editing.
Added in 1.11.0-rc01
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.
Added in 1.11.0-rc01
val Paragraph: LineBreak
Slower, higher quality line breaking for improved readability. Suitable for larger amounts of text.
Added in 1.11.0-rc01
val Unspecified: LineBreak
This represents an unset value, a usual replacement for "null" when a primitive value is desired.
Added in 1.11.0-rc01
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
Added in 1.11.0-rc01
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
strategy
Added in 1.11.0-rc01
val strategy: Strategy
strictness
Added in 1.11.0-rc01
val strictness: Strictness
wordBreak
Added in 1.11.0-rc01
val wordBreak: WordBreak
Functions
copy
Added in 1.11.0-rc01
fun copy(
strategy: Strategy = this.strategy,
strictness: Strictness = this.strictness,
wordBreak: WordBreak = this.wordBreak,
): LineBreak
Companion Object
Properties
Added in 1.11.0-rc01
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. | | 今日は自 | | 由が丘で | | 焼き鳥を | | 食べま | | す。 | +---------+
Added in 1.11.0-rc01
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. | | 今日は | | 自由が丘 | | で焼き鳥 | | を食べ | | ます。 | +---------+
Added in 1.11.0-rc01
actual val Paragraph: LineBreak
Slower, higher quality line breaking for improved readability. Suitable for larger amounts of text.
+---------+ | This | | is an | | example | | text. | | 今日は自 | | 由が丘で | | 焼き鳥を | | 食べま | | す。 | +---------+
Added in 1.11.0-rc01
actual val Unspecified: LineBreak
This represents an unset value, a usual replacement for "null" when a primitive value is desired.