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

Public methods

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

Draws this text layout onto the specified Canvas.

final @Px float

The width constraint of the vertical text in pixels.

final boolean

Capability query to determine whether or not VerticalTextLayout supports vertical text painting.

Public constructors

VerticalTextLayout

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

Public methods

draw

Added in 1.0.0-alpha02
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.

getWidth

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

The width constraint of the vertical text in pixels.

isVerticalTextSupported

Added in 1.0.0-alpha02
public final boolean isVerticalTextSupported()

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