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 added in API 36 (Android 16). For older API levels, it provides a graceful fallback. We will provide a backport to API 31 in the future.

Summary

Public constructors

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

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 or not VerticalTextLayout supports vertical text painting.

Public properties

Float

The width constraint of the vertical text in pixels.

Public constructors

VerticalTextLayout

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

Public functions

draw

Added in 1.0.0-alpha02
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-alpha02
fun isVerticalTextSupported(): Boolean

Capability query to determine whether or not VerticalTextLayout supports vertical text painting. If it is false, calling methods will have no effect.

Public properties

width

Added in 1.0.0-alpha02
val widthFloat

The width constraint of the vertical text in pixels.