Language

LineBreakStyle Enum

Definition

Specifies the line-break rules used by a line-break configuration.

public enum LineBreakStyle
type LineBreakStyle = 
Inheritance
LineBreakStyle

Fields

Name Value Description
Unspecified -1

No line break style is specified.

When Merge(LineBreakConfig) merges a configuration with an unspecified line-break style, it keeps the builder's existing style.

LineBreakConfig override = new LineBreakConfig.Builder()
     .setLineBreakWordStyle(LineBreakConfig.LINE_BREAK_WORD_STYLE_PHRASE)
     .build();  // UNSPECIFIED if no setLineBreakStyle is called.
LineBreakConfig config = new LineBreakConfig.Builder()
     .setLineBreakStyle(LineBreakConfig.LINE_BREAK_STYLE_STRICT)
     .merge(override)
     .build();
// Here, config has LINE_BREAK_STYLE_STRICT for line break config and
// LINE_BREAK_WORD_STYLE_PHRASE for line break word style.

For text layout, this value resolves to None when the target SDK is API level 34 or earlier, and to Auto when the target SDK is API level 35 or later.

Android reference for android.graphics.text.LineBreakConfig.LINE_BREAK_STYLE_UNSPECIFIED.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

None 0

No additional line-break style rules are applied. The default line-break rules still apply.

Android reference for android.graphics.text.LineBreakConfig.LINE_BREAK_STYLE_NONE.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Loose 1

The least restrictive line-break rules are used for line breaking. This setting is typically used for short lines.

Android reference for android.graphics.text.LineBreakConfig.LINE_BREAK_STYLE_LOOSE.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Normal 2

The most common line-break rules are used for line breaking.

Android reference for android.graphics.text.LineBreakConfig.LINE_BREAK_STYLE_NORMAL.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Strict 3

The most strict line-break rules are used for line breaking.

Android reference for android.graphics.text.LineBreakConfig.LINE_BREAK_STYLE_STRICT.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

NoBreak 4

This style prevents automatic line breaking. To keep words on the same line, use LineBreakConfigSpan or the CreateNoBreakSpan() shorthand. Grapheme-based breaks can still occur to prevent clipping.

Android reference for android.graphics.text.LineBreakConfig.LINE_BREAK_STYLE_NO_BREAK.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Auto 5

A special value for the line breaking style option.

The auto option selects a line-break style based on the locale of the text rendering context. You can set the context locale with TextLocales or TextLocales.

If the first locale in a text run's locale list supports Japanese script, this option is equivalent to Strict; otherwise, it is equivalent to None.

Note: future versions may have special line breaking style rules for other locales.

Android reference for android.graphics.text.LineBreakConfig.LINE_BREAK_STYLE_AUTO.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Remarks

Unspecified leaves an existing style unchanged during a merge. Auto is an explicit choice that lets the platform select rules from the text's locale. These values have different merge behavior.

NoBreak suppresses normal automatic breaks, but grapheme-based breaks can still occur to prevent clipping.

This enum exposes the LINE_BREAK_STYLE_* constants from LineBreakConfig.

Applies to