public actual 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.
Properties
strategy
public val strategy: Strategy
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 |
strictness
public val strictness: Strictness
wordBreak
public val wordBreak: WordBreak
Functions
copy
public fun copy(
strategy: Strategy = this.strategy,
strictness: Strictness = this.strictness,
wordBreak: WordBreak = this.wordBreak,
): LineBreak
Members
Companion
public actual companion object
Properties
Simple
public val Simple: LineBreak =
LineBreak(
packBytes(Strategy.Simple.value, Strictness.Normal.value, WordBreak.Default.value)
)
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. | | δ»ζ₯γ―θͺ | | η±γδΈγ§ | | ηΌγι³₯γ | | ι£γΉγΎ | | γγ | +---------+
Heading
public val Heading: LineBreak =
LineBreak(
packBytes(Strategy.Balanced.value, Strictness.Loose.value, WordBreak.Phrase.value)
)
Balanced line lengths, hyphenation, and phrase-based breaking. Suitable for short text such as titles or narrow newspaper columns.
+---------+ | This | | is an | | example | | text. | | δ»ζ₯γ― | | θͺη±γδΈ | | γ§ηΌγι³₯ | | γι£γΉ | | γΎγγ | +---------+
Paragraph
public val Paragraph: LineBreak =
LineBreak(
packBytes(
Strategy.HighQuality.value,
Strictness.Strict.value,
WordBreak.Default.value,
)
)
Slower, higher quality line breaking for improved readability. Suitable for larger amounts of text.
+---------+ | This | | is an | | example | | text. | | δ»ζ₯γ―θͺ | | η±γδΈγ§ | | ηΌγι³₯γ | | ι£γΉγΎ | | γγ | +---------+
Unspecified
public val Unspecified: LineBreak
This represents an unset value, a usual replacement for "null" when a primitive value is desired.
Strategy
public class Strategy internal constructor(internal val value: Int)
The strategy used for line breaking.
Members
Companion
public companion object
Properties
Simple
public val Simple: Strategy
Basic, fast break strategy. Hyphenation, if enabled, is done only for words that don't fit on an entire line by themselves.
+---------+ | This is | | an | | example | | text. | +---------+
HighQuality
public val HighQuality: Strategy
Does whole paragraph optimization for more readable text, including hyphenation if enabled.
+---------+ | This | | is an | | example | | text. | +---------+
Balanced
public val Balanced: Strategy
Attempts to balance the line lengths of the text, also applying automatic hyphenation if enabled. Suitable for small screens.
+-----------------------+ | This is an | | example text. | +-----------------------+
Unspecified
public val Unspecified: Strategy
This represents an unset value, a usual replacement for "null" when a primitive value is desired.
Strictness
public class Strictness internal constructor(internal val value: Int)
Describes the strictness of line breaking, determining before which characters line breaks can be inserted. It is useful when working with CJK scripts.
Members
Companion
public companion object
Properties
Default
public val Default: Strictness
Default breaking rules for the locale, which may correspond to Normal or Strict.
Loose
public val Loose: Strictness
The least restrictive rules, suitable for short lines.
For example, in Japanese it allows breaking before iteration marks, such as γ , γ».
Normal
public val Normal: Strictness
The most common rules for line breaking.
For example, in Japanese it allows breaking before characters like small hiragana (γ), small katakana (γ‘), halfwidth variants (ο½§).
Strict
public val Strict: Strictness
The most stringent rules for line breaking.
For example, in Japanese it does not allow breaking before characters like small hiragana (γ), small katakana (γ‘), halfwidth variants (ο½§).
Unspecified
public val Unspecified: Strictness
This represents an unset value, a usual replacement for "null" when a primitive value is desired.
WordBreak
public class WordBreak internal constructor(internal val value: Int)
Describes how line breaks should be inserted within words.
Functions
toString
override fun toString(): String
Members
Companion
public companion object
Properties
Default
public val Default: WordBreak
Default word breaking rules for the locale. In latin scripts this means inserting line breaks between words, while in languages that don't use whitespace (e.g. Japanese) the line can break between characters.
+---------+ | This is | | an | | example | | text. | | δ»ζ₯γ―θͺ | | η±γδΈγ§ | | ηΌγι³₯γ | | ι£γΉγΎ | | γγ | +---------+
Phrase
public val Phrase: WordBreak
Line breaking is based on phrases. In languages that don't use whitespace (e.g. Japanese), line breaks are not inserted between characters that are part of the same phrase unit. This is ideal for short text such as titles and UI labels.
+---------+ | This | | is an | | example | | text. | | δ»ζ₯γ― | | θͺη±γδΈ | | γ§ηΌγι³₯ | | γι£γΉ | | γΎγγ | +---------+
Unspecified
public val Unspecified: WordBreak
This represents an unset value, a usual replacement for "null" when a primitive value is desired.
public expect class LineBreak private constructor(internal val mask: Int)
Configures line breaking behavior when text wraps automatically to fit its container.
Offers presets for common use cases:
| Preset | Use Case |
|---|---|
Simple |
Text fields and inputs |
Heading |
Titles and short text |
| Paragraph | Body text and long passages |
Customize Android behavior using:
Strategy: Balances layout speed against formatting quality (e.g., greedy vs.Strictness: Adjusts line-breaking rules for East Asian languages (Chinese, Japanese, andWordBreak: Specifies word boundary rules, such as default spacing-based breaking or
paragraph-optimized breaking).
Korean), determining which characters can start or end a line.
phrase-based breaking (ideal for titles).
Members
Companion
public companion object
Properties
Simple
@Stable public val Simple: LineBreak
Basic, fast line breaking. Ideal for text input fields, as it will cause minimal text reflow when editing.
Heading
@Stable public 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.
Paragraph
@Stable public val Paragraph: LineBreak
Slower, higher quality line breaking for improved readability. Suitable for larger amounts of text.
Unspecified
@Stable public val Unspecified: LineBreak
Represents an unset LineBreak value.