{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

RoundRect

public final class RoundRect


An immutable rounded rectangle with custom radii for all four corners.

Summary

Nested types

public static class RoundRect.Companion

Public constructors

RoundRect(
    float left,
    float top,
    float right,
    float bottom,
    @NonNull CornerRadius topLeftCornerRadius,
    @NonNull CornerRadius topRightCornerRadius,
    @NonNull CornerRadius bottomRightCornerRadius,
    @NonNull CornerRadius bottomLeftCornerRadius
)

Public methods

final boolean

Whether the point specified by the given offset (which is assumed to be relative to the origin) lies inside the rounded rectangle.

final float

The offset of the bottom edge of this rectangle from the y axis

final @NonNull CornerRadius

The bottom-left radius

final @NonNull CornerRadius

The bottom-right radius

final float

The distance between the top and bottom edges of this rectangle.

final float

The offset of the left edge of this rectangle from the x axis

final float

The offset of the right edge of this rectangle from the x axis

final float

The offset of the top edge of this rectangle from the y axis

final @NonNull CornerRadius

The top-left radius

final @NonNull CornerRadius

The top-right radius

final float

The distance between the left and right edges of this rectangle.

static final @NonNull RoundRect

A rounded rectangle with all the values set to zero.

@NonNull String

Extension functions

final @NonNull Rect

The bounding box of this rounded rectangle (the rectangle with no rounded corners).

final @NonNull Offset

The offset to the point halfway between the left and right and the top and bottom edges of this rectangle.

final float
final float

The lesser of the magnitudes of the RoundRect.width and the RoundRect.height of this rounded rectangle.

final @NonNull Rect

The non-rounded rectangle that is constrained by the smaller of the two diagonals, with each diagonal traveling through the middle of the curve corners.

final boolean

Whether this rounded rectangle would draw as a circle.

final boolean

Whether this rounded rectangle has no side with a straight section.

final boolean

Whether this rounded rectangle encloses a non-zero area.

final boolean

Whether all coordinates of this rounded rectangle are finite.

final boolean

Whether this rounded rectangle is a simple rectangle with zero corner radii.

final boolean

Returns true if the rounded rectangle have the same radii in both the horizontal and vertical direction for all corners.

final @NonNull RoundRect

Returns a new RoundRect translated by the given offset.

Public constructors

RoundRect

public RoundRect(
    float left,
    float top,
    float right,
    float bottom,
    @NonNull CornerRadius topLeftCornerRadius,
    @NonNull CornerRadius topRightCornerRadius,
    @NonNull CornerRadius bottomRightCornerRadius,
    @NonNull CornerRadius bottomLeftCornerRadius
)

Public methods

contains

public final boolean contains(@NonNull Offset point)

Whether the point specified by the given offset (which is assumed to be relative to the origin) lies inside the rounded rectangle.

This method may allocate (and cache) a copy of the object with normalized radii the first time it is called on a particular RoundRect instance. When using this method, prefer to reuse existing RoundRects rather than recreating the object each time.

getBottom

public final float getBottom()

The offset of the bottom edge of this rectangle from the y axis

getBottomLeftCornerRadius

public final @NonNull CornerRadius getBottomLeftCornerRadius()

The bottom-left radius

getBottomRightCornerRadius

public final @NonNull CornerRadius getBottomRightCornerRadius()

The bottom-right radius

getHeight

public final float getHeight()

The distance between the top and bottom edges of this rectangle.

getLeft

public final float getLeft()

The offset of the left edge of this rectangle from the x axis

getRight

public final float getRight()

The offset of the right edge of this rectangle from the x axis

getTop

public final float getTop()

The offset of the top edge of this rectangle from the y axis

getTopLeftCornerRadius

public final @NonNull CornerRadius getTopLeftCornerRadius()

The top-left radius

getTopRightCornerRadius

public final @NonNull CornerRadius getTopRightCornerRadius()

The top-right radius

getWidth

public final float getWidth()

The distance between the left and right edges of this rectangle.

getZero

public static final @NonNull RoundRect getZero()

A rounded rectangle with all the values set to zero.

toString

public @NonNull String toString()

Extension functions

RoundRectKt.getBoundingRect

public final @NonNull Rect RoundRectKt.getBoundingRect(@NonNull RoundRect receiver)

The bounding box of this rounded rectangle (the rectangle with no rounded corners).

RoundRectKt.getCenter

public final @NonNull Offset RoundRectKt.getCenter(@NonNull RoundRect receiver)

The offset to the point halfway between the left and right and the top and bottom edges of this rectangle.

RoundRectKt.getMaxDimension

public final float RoundRectKt.getMaxDimension(@NonNull RoundRect receiver)

RoundRectKt.getMinDimension

public final float RoundRectKt.getMinDimension(@NonNull RoundRect receiver)

The lesser of the magnitudes of the RoundRect.width and the RoundRect.height of this rounded rectangle.

RoundRectKt.getSafeInnerRect

public final @NonNull Rect RoundRectKt.getSafeInnerRect(@NonNull RoundRect receiver)

The non-rounded rectangle that is constrained by the smaller of the two diagonals, with each diagonal traveling through the middle of the curve corners. The middle of a corner is the intersection of the curve with its respective quadrant bisector.

RoundRectKt.isCircle

public final boolean RoundRectKt.isCircle(@NonNull RoundRect receiver)

Whether this rounded rectangle would draw as a circle.

RoundRectKt.isEllipse

public final boolean RoundRectKt.isEllipse(@NonNull RoundRect receiver)

Whether this rounded rectangle has no side with a straight section.

RoundRectKt.isEmpty

public final boolean RoundRectKt.isEmpty(@NonNull RoundRect receiver)

Whether this rounded rectangle encloses a non-zero area. Negative areas are considered empty.

RoundRectKt.isFinite

public final boolean RoundRectKt.isFinite(@NonNull RoundRect receiver)

Whether all coordinates of this rounded rectangle are finite.

RoundRectKt.isRect

public final boolean RoundRectKt.isRect(@NonNull RoundRect receiver)

Whether this rounded rectangle is a simple rectangle with zero corner radii.

RoundRectKt.isSimple

public final boolean RoundRectKt.isSimple(@NonNull RoundRect receiver)

Returns true if the rounded rectangle have the same radii in both the horizontal and vertical direction for all corners.

RoundRectKt.translate

public final @NonNull RoundRect RoundRectKt.translate(@NonNull RoundRect receiver, @NonNull Offset offset)

Returns a new RoundRect translated by the given offset.