Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/graphics/Outline#pubctors) \| [Methods](https://developer.android.com/reference/android/graphics/Outline#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/graphics/Outline#inhmethods)

# Outline

*** ** * ** ***


`
public

final

class
Outline
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.graphics.Outline |

<br />

*** ** * ** ***

Defines a simple shape, used for bounding graphical regions.


Can be computed for a View, or computed by a Drawable, to drive the shape of
shadows cast by a View, or to clip the contents of the View.
**See also:**

- `https://developer.android.com/reference/android/view/ViewOutlineProvider`
- `https://developer.android.com/reference/android/view/View#setOutlineProvider(android.view.ViewOutlineProvider)`
- `https://developer.android.com/reference/android/graphics/drawable/Drawable#getOutline(android.graphics.Outline)`

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/graphics/Outline#Outline()() ` Constructs an empty Outline. |
| ` https://developer.android.com/reference/android/graphics/Outline#Outline(android.graphics.Outline)(https://developer.android.com/reference/android/graphics/Outline src) ` Constructs an Outline with a copy of the data in src. |

| ### Public methods ||
|---|---|
| ` boolean` | ` https://developer.android.com/reference/android/graphics/Outline#canClip()() ` Returns whether the outline can be used to clip a View. |
| ` float` | ` https://developer.android.com/reference/android/graphics/Outline#getAlpha()() ` Returns the alpha represented by the Outline. |
| ` float` | ` https://developer.android.com/reference/android/graphics/Outline#getRadius()() ` Returns the rounded rect radius, if set, or a value less than 0 if a path has been set via `https://developer.android.com/reference/android/graphics/Outline#setPath(android.graphics.Path)`. |
| ` boolean` | ` https://developer.android.com/reference/android/graphics/Outline#getRect(android.graphics.Rect)(https://developer.android.com/reference/android/graphics/Rect outRect) ` Populates `outBounds` with the outline bounds, if set, and returns `true`. |
| ` boolean` | ` https://developer.android.com/reference/android/graphics/Outline#isEmpty()() ` Returns whether the Outline is empty. |
| ` boolean` | ` https://developer.android.com/reference/android/graphics/Outline#isOuterShadowOnly()() ` Returns whether the shadow cast by this Outline is only drawn outside the outline. |
| ` void` | ` https://developer.android.com/reference/android/graphics/Outline#offset(int,%20int)(int dx, int dy) ` Offsets the Outline by (dx,dy). |
| ` void` | ` https://developer.android.com/reference/android/graphics/Outline#set(android.graphics.Outline)(https://developer.android.com/reference/android/graphics/Outline src) ` Replace the contents of this Outline with the contents of src. |
| ` void` | ` https://developer.android.com/reference/android/graphics/Outline#setAlpha(float)(float alpha) ` Sets the alpha represented by the Outline - the degree to which the producer is guaranteed to be opaque over the Outline's shape. |
| ` void` | ` https://developer.android.com/reference/android/graphics/Outline#setConvexPath(android.graphics.Path)(https://developer.android.com/reference/android/graphics/Path convexPath) ` *This method was deprecated in API level 30. As of `https://developer.android.com/reference/android/os/Build.VERSION_CODES#Q`, the restriction that the path must be convex is removed. However, the API is misnamed until `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R`, when `https://developer.android.com/reference/android/graphics/Outline#setPath(android.graphics.Path)` is introduced. Use `https://developer.android.com/reference/android/graphics/Outline#setPath(android.graphics.Path)` instead.* |
| ` void` | ` https://developer.android.com/reference/android/graphics/Outline#setEmpty()() ` Sets the outline to be empty. |
| ` void` | ` https://developer.android.com/reference/android/graphics/Outline#setOuterShadowOnly(boolean)(boolean outerShadowOnly) ` Sets whether the shadow cast by this Outline should only be drawn outside the outline. |
| ` void` | ` https://developer.android.com/reference/android/graphics/Outline#setOval(android.graphics.Rect)(https://developer.android.com/reference/android/graphics/Rect rect) ` Convenience for `https://developer.android.com/reference/android/graphics/Outline#setOval(int,%20int,%20int,%20int)` |
| ` void` | ` https://developer.android.com/reference/android/graphics/Outline#setOval(int,%20int,%20int,%20int)(int left, int top, int right, int bottom) ` Sets the outline to the oval defined by input rect. |
| ` void` | ` https://developer.android.com/reference/android/graphics/Outline#setPath(android.graphics.Path)(https://developer.android.com/reference/android/graphics/Path path) ` Sets the Outline to a `https://developer.android.com/reference/android/graphics/Path`. |
| ` void` | ` https://developer.android.com/reference/android/graphics/Outline#setRect(android.graphics.Rect)(https://developer.android.com/reference/android/graphics/Rect rect) ` Convenience for `https://developer.android.com/reference/android/graphics/Outline#setRect(int,%20int,%20int,%20int)` |
| ` void` | ` https://developer.android.com/reference/android/graphics/Outline#setRect(int,%20int,%20int,%20int)(int left, int top, int right, int bottom) ` Sets the Outline to the rect defined by the input coordinates. |
| ` void` | ` https://developer.android.com/reference/android/graphics/Outline#setRoundRect(android.graphics.Rect,%20float)(https://developer.android.com/reference/android/graphics/Rect rect, float radius) ` Convenience for `https://developer.android.com/reference/android/graphics/Outline#setRoundRect(int,%20int,%20int,%20int,%20float)` |
| ` void` | ` https://developer.android.com/reference/android/graphics/Outline#setRoundRect(int,%20int,%20int,%20int,%20float)(int left, int top, int right, int bottom, float radius) ` Sets the Outline to the rounded rect defined by the input coordinates and corner radius. |

### Inherited methods

From class `

https://developer.android.com/reference/java/lang/Object

` `


https://developer.android.com/reference/java/lang/Object` `
https://developer.android.com/reference/java/lang/Object#clone()()
`

Creates and returns a copy of this object.


`


boolean` `
https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj)
`

Indicates whether some other object is "equal to" this one.


`


void` `
https://developer.android.com/reference/java/lang/Object#finalize()()
`

Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.


`


final

https://developer.android.com/reference/java/lang/Class<?>` `
https://developer.android.com/reference/java/lang/Object#getClass()()
`

Returns the runtime class of this `Object`.


`


int` `
https://developer.android.com/reference/java/lang/Object#hashCode()()
`

Returns a hash code value for the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notify()()
`

Wakes up a single thread that is waiting on this object's
monitor.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notifyAll()()
`

Wakes up all threads that are waiting on this object's monitor.


`


https://developer.android.com/reference/java/lang/String` `
https://developer.android.com/reference/java/lang/Object#toString()()
`

Returns a string representation of the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos)
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*, or until a
certain amount of real time has elapsed.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis)
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*, or until a
certain amount of real time has elapsed.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait()()
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*.


## Public constructors

### Outline

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Outline ()
```

Constructs an empty Outline. Call one of the setter methods to make
the outline valid for use with a View.

<br />

### Outline

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Outline (Outline src)
```

Constructs an Outline with a copy of the data in src.

<br />

| Parameters ||
|---|---|
| `src` | `Outline`: This value cannot be `null`. <br /> |

## Public methods

### canClip

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean canClip ()
```

Returns whether the outline can be used to clip a View.


As of API 33, all Outline shapes support clipping. Prior to API 33, only Outlines that
could be represented as a rectangle, circle, or round rect supported clipping.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/View#setClipToOutline(boolean)`

### getAlpha

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public float getAlpha ()
```

Returns the alpha represented by the Outline.

<br />

| Returns ||
|---|---|
| `float` | <br /> |

### getRadius

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public float getRadius ()
```

Returns the rounded rect radius, if set, or a value less than 0 if a path has
been set via `https://developer.android.com/reference/android/graphics/Outline#setPath(android.graphics.Path)`. A return value of `0`
indicates a non-rounded rect.

<br />

| Returns ||
|---|---|
| `float` | the rounded rect radius, or value \< 0 <br /> |

### getRect

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean getRect (Rect outRect)
```

Populates `outBounds` with the outline bounds, if set, and returns
`true`. If no outline bounds are set, or if a path has been set
via `https://developer.android.com/reference/android/graphics/Outline#setPath(android.graphics.Path)`, returns `false`.

<br />

| Parameters ||
|---|---|
| `outRect` | `Rect`: the rect to populate with the outline bounds, if set. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if `outBounds` was populated with outline bounds, or `false` if no outline bounds are set <br /> |

### isEmpty

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isEmpty ()
```

Returns whether the Outline is empty.


Outlines are empty when constructed, or if `https://developer.android.com/reference/android/graphics/Outline#setEmpty()` is called,
until a setter method is called

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/graphics/Outline#setEmpty()`

### isOuterShadowOnly

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public boolean isOuterShadowOnly ()
```

Returns whether the shadow cast by this Outline is only drawn outside the outline.

<br />

| Returns ||
|---|---|
| `boolean` | true if the shadow is only drawn outside the outline boundary, false otherwise <br /> |

### offset

Added in [API level 22](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void offset (int dx, 
                int dy)
```

Offsets the Outline by (dx,dy). Offsetting is cumulative, so additional calls to
offset() will add to previous offset values. Offset only applies to the current
geometry (setRect(), setPath(), etc.); setting new geometry resets any existing
offset.

<br />

| Parameters ||
|---|---|
| `dx` | `int` <br /> |
| `dy` | `int` <br /> |

### set

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void set (Outline src)
```

Replace the contents of this Outline with the contents of src.

<br />

| Parameters ||
|---|---|
| `src` | `Outline`: Source outline to copy from. This value cannot be `null`. <br /> |

### setAlpha

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setAlpha (float alpha)
```

Sets the alpha represented by the Outline - the degree to which the
producer is guaranteed to be opaque over the Outline's shape.


An alpha value of `0.0f` either represents completely
transparent content, or content that isn't guaranteed to fill the shape
it publishes.


Content producing a fully opaque (alpha = `1.0f`) outline is
assumed by the drawing system to fully cover content beneath it,
meaning content beneath may be optimized away.

<br />

| Parameters ||
|---|---|
| `alpha` | `float`: Value is between 0.0f and 1.0f inclusive <br /> |

### setConvexPath

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setConvexPath (Path convexPath)
```


**This method was deprecated
in API level 30.**   

As of `https://developer.android.com/reference/android/os/Build.VERSION_CODES#Q`, the restriction
that the path must be convex is removed. However, the API is misnamed until
`https://developer.android.com/reference/android/os/Build.VERSION_CODES#R`, when `https://developer.android.com/reference/android/graphics/Outline#setPath(android.graphics.Path)` is
introduced. Use `https://developer.android.com/reference/android/graphics/Outline#setPath(android.graphics.Path)` instead.

Sets the Outline to a
`https://developer.android.com/reference/android/graphics/Path#isConvex()`.

<br />

| Parameters ||
|---|---|
| `convexPath` | `Path`: used to construct the Outline. As of `https://developer.android.com/reference/android/os/Build.VERSION_CODES#Q`, it is no longer required to be convex. This value cannot be `null`. <br /> |

### setEmpty

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setEmpty ()
```

Sets the outline to be empty.

<br />

**See also:**

- `https://developer.android.com/reference/android/graphics/Outline#isEmpty()`

### setOuterShadowOnly

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public void setOuterShadowOnly (boolean outerShadowOnly)
```

Sets whether the shadow cast by this Outline should only be drawn outside the outline.


If enabled, the shadow under the outline area will be clipped out, the default value is
`false`.

<br />

| Parameters ||
|---|---|
| `outerShadowOnly` | `boolean`: whether to draw the shadow only outside the outline boundary <br /> |

### setOval

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setOval (Rect rect)
```

Convenience for `https://developer.android.com/reference/android/graphics/Outline#setOval(int,%20int,%20int,%20int)`

<br />

| Parameters ||
|---|---|
| `rect` | `Rect`: This value cannot be `null`. <br /> |

### setOval

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setOval (int left, 
                int top, 
                int right, 
                int bottom)
```

Sets the outline to the oval defined by input rect.

<br />

| Parameters ||
|---|---|
| `left` | `int` <br /> |
| `top` | `int` <br /> |
| `right` | `int` <br /> |
| `bottom` | `int` <br /> |

### setPath

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setPath (Path path)
```

Sets the Outline to a `https://developer.android.com/reference/android/graphics/Path`.

<br />

| Parameters ||
|---|---|
| `path` | `Path`: used to construct the Outline. This value cannot be `null`. <br /> |

### setRect

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setRect (Rect rect)
```

Convenience for `https://developer.android.com/reference/android/graphics/Outline#setRect(int,%20int,%20int,%20int)`

<br />

| Parameters ||
|---|---|
| `rect` | `Rect`: This value cannot be `null`. <br /> |

### setRect

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setRect (int left, 
                int top, 
                int right, 
                int bottom)
```

Sets the Outline to the rect defined by the input coordinates.

<br />

| Parameters ||
|---|---|
| `left` | `int` <br /> |
| `top` | `int` <br /> |
| `right` | `int` <br /> |
| `bottom` | `int` <br /> |

### setRoundRect

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setRoundRect (Rect rect, 
                float radius)
```

Convenience for `https://developer.android.com/reference/android/graphics/Outline#setRoundRect(int,%20int,%20int,%20int,%20float)`

<br />

| Parameters ||
|---|---|
| `rect` | `Rect`: This value cannot be `null`. <br /> |
| `radius` | `float` <br /> |

### setRoundRect

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setRoundRect (int left, 
                int top, 
                int right, 
                int bottom, 
                float radius)
```

Sets the Outline to the rounded rect defined by the input coordinates and corner radius.


Passing a zero radius is equivalent to calling `https://developer.android.com/reference/android/graphics/Outline#setRect(int,%20int,%20int,%20int)`

<br />

| Parameters ||
|---|---|
| `left` | `int` <br /> |
| `top` | `int` <br /> |
| `right` | `int` <br /> |
| `bottom` | `int` <br /> |
| `radius` | `float` <br /> |