# DisplayShapeCompat

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/view/DisplayShapeCompat.java+class:androidx.core.view.DisplayShapeCompat) Added in [1.18.0](https://developer.android.com/jetpack/androidx/releases/core#1.18.0)

*** ** * ** ***


```
public final class DisplayShapeCompat
```

<br />

*** ** * ** ***

Compatibility class for representing the physical shape of a display.

This class can be used to obtain a `https://developer.android.com/reference/android/graphics/Path.html` 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 `https://developer.android.com/reference/androidx/core/view/DisplayShapeCompat` can be created in a few ways:

- Using `https://developer.android.com/reference/androidx/core/view/DisplayShapeCompat#create(java.lang.String,float,int,int)` to parse an SVG path data string. This is suitable for custom or complex display shapes.
- Using `https://developer.android.com/reference/androidx/core/view/DisplayShapeCompat#create(int,int,boolean,int,int,int,int)` to define a common shape, such as a circle or a rectangle with specified corner radii.

The `https://developer.android.com/reference/android/graphics/Path.html` representing the shape can be retrieved using `https://developer.android.com/reference/androidx/core/view/DisplayShapeCompat#getPath()`.

## Summary

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/core/view/DisplayShapeCompat#equals(java.lang.Object)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/Object.html o)` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Path.html` | `https://developer.android.com/reference/androidx/core/view/DisplayShapeCompat#getPath()()` Returns a `https://developer.android.com/reference/android/graphics/Path.html` of the display shape. |
| `int` | `https://developer.android.com/reference/androidx/core/view/DisplayShapeCompat#hashCode()()` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/core/view/DisplayShapeCompat#toString()()` |

## Public methods

### equals

```
public boolean equals(@Nullable Object o)
```

### getPath

Added in [1.18.0](https://developer.android.com/jetpack/androidx/releases/core#1.18.0)

```
public @NonNull Path getPath()
```

Returns a `https://developer.android.com/reference/android/graphics/Path.html` of the display shape. Returns an empty `https://developer.android.com/reference/android/graphics/Path.html` if the shape information is not available or if parsing fails.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If the display spec string cannot be parsed. |

### hashCode

```
public int hashCode()
```

### toString

```
public @NonNull String toString()
```