LineHeightStyle.Trim


Defines whether to trim the extra space from the top of the first line and the bottom of the last line of text.

This setting only takes effect when PlatformParagraphStyle.includeFontPadding is set to false.

The behavior of Trim depends on the selected Mode.

Mode.Fixed (Default), or Mode.Minimum

Trims extra vertical space only when the configured line height is taller than the font's default. This prevents clipping of glyphs by ensuring trimming only removes extra space.

Mode.Tight

Trimming is applied even when the configured line height is shorter than the font's default. This offers more aggressive trimming but carries a risk of clipping tall glyphs that extend beyond the shortened line height.

Warning: Use Mode.Tight with caution, as it can lead to parts of characters being cut off. Ensure you have tested your text with various glyphs before using this mode in production.

Summary

Public companion properties

LineHeightStyle.Trim

Trim the space that would be added to the top of the first line and bottom of the last line as a result of the line height.

Cmn
LineHeightStyle.Trim

Trim the space that would be added to the top of the first line as a result of the line height.

Cmn
LineHeightStyle.Trim

Trim the space that would be added to the bottom of the last line as a result of the line height.

Cmn
LineHeightStyle.Trim

Do not trim first line top or last line bottom.

Cmn

Public functions

open String
Cmn

Public companion properties

Both

val BothLineHeightStyle.Trim

Trim the space that would be added to the top of the first line and bottom of the last line as a result of the line height. This feature is available only when PlatformParagraphStyle.includeFontPadding is false.

For example, when line height is 3.em, and Alignment is Alignment.Center, the first and last line has 2.em height and the height from first line baseline to second line baseline is still 3.em:

+--------+
| Line1  |
|        |
|--------|
|        |
| Line2  |
+--------+

FirstLineTop

val FirstLineTopLineHeightStyle.Trim

Trim the space that would be added to the top of the first line as a result of the line height. Single line text is both the first and last line. This feature is available only when PlatformParagraphStyle.includeFontPadding is false.

For example, when line height is 3.em, and Alignment is Alignment.Center, the first line has 2.em height and the height from first line baseline to second line baseline is still 3.em:

+--------+
| Line1  |
|        |
|--------|
|        |
| Line2  |
|        |
+--------+

LastLineBottom

val LastLineBottomLineHeightStyle.Trim

Trim the space that would be added to the bottom of the last line as a result of the line height. Single line text is both the first and last line. This feature is available only when PlatformParagraphStyle.includeFontPadding is false.

For example, when line height is 3.em, and Alignment is Alignment.Center, the last line has 2.em height and the height from first line baseline to second line baseline is still 3.em:

+--------+
|        |
| Line1  |
|        |
|--------|
|        |
| Line2  |
+--------+

None

val NoneLineHeightStyle.Trim

Do not trim first line top or last line bottom.

For example, when line height is 3.em, and Alignment is Alignment.Center, the first line height, last line height and the height from first line baseline to second line baseline are 3.em:

+--------+
|        |
| Line1  |
|        |
|--------|
|        |
| Line2  |
|        |
+--------+

Public functions

toString

open fun toString(): String