VerticalTextLayout


public final 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(
    @NonNull CharSequence text,
    int start,
    int end,
    @NonNull TextPaint paint,
    @Px float height,
    @NonNull TextOrientation orientation
)

Public methods

final void
draw(@NonNull Canvas canvas, @Px float x, @Px float y)

Draws this text layout onto the specified Canvas.

final int

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

final @Px float

The computed width of the vertical text layout in pixels.

final boolean

Capability query to determine whether VerticalTextLayout supports vertical text painting.

Public constructors

VerticalTextLayout

Added in 1.0.0-alpha05
public VerticalTextLayout(
    @NonNull CharSequence text,
    int start,
    int end,
    @NonNull TextPaint paint,
    @Px float height,
    @NonNull TextOrientation orientation
)

Public methods

draw

Added in 1.0.0-alpha05
public final void draw(@NonNull Canvas canvas, @Px float x, @Px float y)

Draws this text layout onto the specified Canvas.

Parameters
@NonNull Canvas canvas

The Canvas to draw onto.

@Px float x

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

@Px float y

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

getLineCount

Added in 1.0.0-alpha05
public final int getLineCount()

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

getWidth

Added in 1.0.0-alpha05
public final @Px float getWidth()

The computed width of the vertical text layout in pixels.

isVerticalTextSupported

Added in 1.0.0-alpha05
public final boolean isVerticalTextSupported()

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