VerticalTextLayout


class VerticalTextLayout


Represents the result of laying out text vertically.

This class encapsulates the result of a vertical text layout process. It stores the layout's properties and provides methods to draw the layout on a Canvas.

NOTE: Currently, this API leverages a platform feature introduced in API 36 (Android 16). On older API levels, it falls back to a no-op.

Summary

Public constructors

VerticalTextLayout(
    text: CharSequence,
    start: Int,
    end: Int,
    paint: TextPaint,
    height: @Px Float,
    orientation: TextOrientation
)

Public functions

Unit
draw(canvas: Canvas, x: @Px Float, y: @Px Float)

Draws this text layout onto the specified Canvas.

Boolean

Capability query to determine whether VerticalTextLayout supports vertical text painting.

Public properties

Int

The number of lines (columns) in this vertical text layout.

Float

The computed width of the vertical text layout in pixels.

Public constructors

VerticalTextLayout

Added in 1.0.0-alpha05
VerticalTextLayout(
    text: CharSequence = "",
    start: Int = 0,
    end: Int = text.length,
    paint: TextPaint = TextPaint(),
    height: @Px Float = 0.0f,
    orientation: TextOrientation = TextOrientation.Mixed
)

Public functions

draw

Added in 1.0.0-alpha05
fun draw(canvas: Canvas, x: @Px Float, y: @Px Float): Unit

Draws this text layout onto the specified Canvas.

Parameters
canvas: Canvas

The Canvas to draw onto.

x: @Px Float

The horizontal offset in pixels. The drawing origin is the top-right corner.

y: @Px Float

The vertical offset in pixels. The drawing origin is the top-right corner.

isVerticalTextSupported

Added in 1.0.0-alpha05
fun isVerticalTextSupported(): Boolean

Capability query to determine whether VerticalTextLayout supports vertical text painting. If this returns false, draw will have no effect.

Public properties

lineCount

Added in 1.0.0-alpha05
val lineCountInt

The number of lines (columns) in this vertical text layout.

width

Added in 1.0.0-alpha05
val widthFloat

The computed width of the vertical text layout in pixels.