DisplayShapeCompat


public final class DisplayShapeCompat


Compatibility class for representing the physical shape of a display.

This class can be used to obtain a Path representing the display's shape, which can be useful for drawing or layout purposes, especially on devices with non-rectangular displays (e.g., circular or displays with rounded corners).

Instances of DisplayShapeCompat can be created in a few ways:

  • Using create to parse an SVG path data string. This is suitable for custom or complex display shapes.
  • Using create to define a common shape, such as a circle or a rectangle with specified corner radii.
The Path representing the shape can be retrieved using getPath.

Summary

Public methods

boolean
@NonNull Path

Returns a Path of the display shape.

int
@NonNull String

Public methods

equals

public boolean equals(@Nullable Object o)

getPath

public @NonNull Path getPath()

Returns a Path of the display shape. Returns an empty Path if the shape information is not available or if parsing fails.

Throws
java.lang.IllegalArgumentException

If the display spec string cannot be parsed.

hashCode

public int hashCode()

toString

public @NonNull String toString()