ParagraphStyle

Class

Common
class ParagraphStyle(
    val textAlign: TextAlign = TextAlign.Unspecified,
    val textDirection: TextDirection = TextDirection.Unspecified,
    val lineHeight: TextUnit = TextUnit.Unspecified,
    val textIndent: TextIndent? = null,
    val platformStyle: PlatformParagraphStyle? = null,
    val lineHeightStyle: LineHeightStyle? = null,
    val lineBreak: LineBreak = LineBreak.Unspecified,
    val hyphens: Hyphens = Hyphens.Unspecified,
    val textMotion: TextMotion? = null,
) : AnnotatedString.Annotation

Paragraph styling configuration for a paragraph. The difference between SpanStyle and ParagraphStyle is that, ParagraphStyle can be applied to a whole Paragraph while SpanStyle can be applied at the character level. Once a portion of the text is marked with a ParagraphStyle, that portion will be separated from the remaining as if a line feed character was added.

Parameters

textAlignThe alignment of the text within the lines of the paragraph.
textDirectionThe algorithm to be used to resolve the final text direction: Left To Right or Right To Left.
lineHeightLine height for the Paragraph in TextUnit unit, e.g. SP or EM.
textIndentThe indentation of the paragraph.
platformStylePlatform specific ParagraphStyle parameters.
lineHeightStylethe configuration for line height such as vertical alignment of the line, whether to apply additional space as a result of line height to top of first line top and bottom of last line. The configuration is applied only when a lineHeight is defined. When null, LineHeightStyle.Default is used.
lineBreakThe line breaking configuration for the text.
hyphensThe configuration of hyphenation.
textMotionText character placement, whether to optimize for animated or static text.

Secondary Constructors

constructor(
    textAlign: TextAlign? = null,
    textDirection: TextDirection? = null,
    lineHeight: TextUnit = TextUnit.Unspecified,
    textIndent: TextIndent? = null,
    platformStyle: PlatformParagraphStyle? = null,
    lineHeightStyle: LineHeightStyle? = null,
    lineBreak: LineBreak? = null,
    hyphens: Hyphens? = null,
    textMotion: TextMotion? = null,
) : this(
    textAlign = textAlign ?: TextAlign.Unspecified,
    textDirection = textDirection ?: TextDirection.Unspecified,
    lineHeight = lineHeight,
    textIndent = textIndent,
    platformStyle = platformStyle,
    lineHeightStyle = lineHeightStyle,
    lineBreak = lineBreak ?: LineBreak.Unspecified,
    hyphens = hyphens ?: Hyphens.Unspecified,
    textMotion = textMotion,
)
constructor(
    textAlign: TextAlign? = null,
    textDirection: TextDirection? = null,
    lineHeight: TextUnit = TextUnit.Unspecified,
    textIndent: TextIndent? = null,
) : this(
    textAlign = textAlign ?: TextAlign.Unspecified,
    textDirection = textDirection ?: TextDirection.Unspecified,
    lineHeight = lineHeight,
    textIndent = textIndent,
    platformStyle = null,
    lineHeightStyle = null,
    lineBreak = LineBreak.Unspecified,
    hyphens = Hyphens.Unspecified,
    textMotion = null,
)
constructor(
    textAlign: TextAlign? = null,
    textDirection: TextDirection? = null,
    lineHeight: TextUnit = TextUnit.Unspecified,
    textIndent: TextIndent? = null,
    platformStyle: PlatformParagraphStyle? = null,
    lineHeightStyle: LineHeightStyle? = null,
) : this(
    textAlign = textAlign ?: TextAlign.Unspecified,
    textDirection = textDirection ?: TextDirection.Unspecified,
    lineHeight = lineHeight,
    textIndent = textIndent,
    platformStyle = platformStyle,
    lineHeightStyle = lineHeightStyle,
    lineBreak = LineBreak.Unspecified,
    hyphens = Hyphens.Unspecified,
    textMotion = null,
)
constructor(
    textAlign: TextAlign? = null,
    textDirection: TextDirection? = null,
    lineHeight: TextUnit = TextUnit.Unspecified,
    textIndent: TextIndent? = null,
    platformStyle: PlatformParagraphStyle? = null,
    lineHeightStyle: LineHeightStyle? = null,
    lineBreak: LineBreak? = null,
    hyphens: Hyphens? = null,
) : this(
    textAlign = textAlign ?: TextAlign.Unspecified,
    textDirection = textDirection ?: TextDirection.Unspecified,
    lineHeight = lineHeight,
    textIndent = textIndent,
    platformStyle = platformStyle,
    lineHeightStyle = lineHeightStyle,
    lineBreak = lineBreak ?: LineBreak.Unspecified,
    hyphens = hyphens ?: Hyphens.Unspecified,
    textMotion = null,
)

Properties

Common

Deprecated Kept for backwards compatibility.

val deprecated_boxing_textAlign: TextAlign?
Common

Deprecated Kept for backwards compatibility.

val deprecated_boxing_textDirection: TextDirection?
Common

Deprecated Kept for backwards compatibility.

val deprecated_boxing_hyphens: Hyphens?
Common

Deprecated Kept for backwards compatibility.

val deprecated_boxing_lineBreak: LineBreak?

Functions

fun merge(other: ParagraphStyle? = null): ParagraphStyle

Returns a new paragraph style that is a combination of this style and the given other style.

If the given paragraph style is null, returns this paragraph style.

operator fun plus(other: ParagraphStyle): ParagraphStyle

Plus operator overload that applies a merge.

fun copy(
        textAlign: TextAlign? = this.textAlign,
        textDirection: TextDirection? = this.textDirection,
        lineHeight: TextUnit = this.lineHeight,
        textIndent: TextIndent? = this.textIndent,
    ): ParagraphStyle
fun copy(
        textAlign: TextAlign? = this.textAlign,
        textDirection: TextDirection? = this.textDirection,
        lineHeight: TextUnit = this.lineHeight,
        textIndent: TextIndent? = this.textIndent,
        platformStyle: PlatformParagraphStyle? = this.platformStyle,
        lineHeightStyle: LineHeightStyle? = this.lineHeightStyle,
    ): ParagraphStyle
fun copy(
        textAlign: TextAlign? = this.textAlign,
        textDirection: TextDirection? = this.textDirection,
        lineHeight: TextUnit = this.lineHeight,
        textIndent: TextIndent? = this.textIndent,
        platformStyle: PlatformParagraphStyle? = this.platformStyle,
        lineHeightStyle: LineHeightStyle? = this.lineHeightStyle,
        lineBreak: LineBreak? = this.lineBreak,
        hyphens: Hyphens? = this.hyphens,
    ): ParagraphStyle
fun copy(
        textAlign: TextAlign? = this.textAlign,
        textDirection: TextDirection? = this.textDirection,
        lineHeight: TextUnit = this.lineHeight,
        textIndent: TextIndent? = this.textIndent,
        platformStyle: PlatformParagraphStyle? = this.platformStyle,
        lineHeightStyle: LineHeightStyle? = this.lineHeightStyle,
        lineBreak: LineBreak? = this.lineBreak,
        hyphens: Hyphens? = this.hyphens,
        textMotion: TextMotion? = this.textMotion,
    ): ParagraphStyle
fun copy(
        textAlign: TextAlign = this.textAlign,
        textDirection: TextDirection = this.textDirection,
        lineHeight: TextUnit = this.lineHeight,
        textIndent: TextIndent? = this.textIndent,
        platformStyle: PlatformParagraphStyle? = this.platformStyle,
        lineHeightStyle: LineHeightStyle? = this.lineHeightStyle,
        lineBreak: LineBreak = this.lineBreak,
        hyphens: Hyphens = this.hyphens,
        textMotion: TextMotion? = this.textMotion,
    ): ParagraphStyle