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

# ViewOverlay

*** ** * ** ***

` public class ViewOverlay `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

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

Known direct subclasses [ViewGroupOverlay](https://developer.android.com/reference/android/view/ViewGroupOverlay) [ViewGroupOverlay](https://developer.android.com/reference/android/view/ViewGroupOverlay) A group overlay is an extra layer that sits on top of a ViewGroup (the "host view") which is drawn after all other content in that view (including the view group's children).   

*** ** * ** ***

An overlay is an extra layer that sits on top of a View (the "host view") which is drawn after all other content in that view (including children, if the view is a ViewGroup). Interaction with the overlay layer is done by adding and removing drawables.

An overlay requested from a ViewGroup is of type `https://developer.android.com/reference/android/view/ViewGroupOverlay`, which also supports adding and removing views.

<br />

**See also:**

- `https://developer.android.com/reference/android/view/View#getOverlay()`
- `https://developer.android.com/reference/android/view/ViewGroup#getOverlay()`
- `https://developer.android.com/reference/android/view/ViewGroupOverlay`

## Summary

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/view/ViewOverlay#add(android.graphics.drawable.Drawable)(https://developer.android.com/reference/android/graphics/drawable/Drawable drawable) ` Adds a `https://developer.android.com/reference/android/graphics/drawable/Drawable` to the overlay. |
| ` void` | ` https://developer.android.com/reference/android/view/ViewOverlay#clear()() ` Removes all content from the overlay. |
| ` void` | ` https://developer.android.com/reference/android/view/ViewOverlay#remove(android.graphics.drawable.Drawable)(https://developer.android.com/reference/android/graphics/drawable/Drawable drawable) ` Removes the specified `https://developer.android.com/reference/android/graphics/drawable/Drawable` from the overlay. |

### 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 methods

### add

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

```
public void add (Drawable drawable)
```

Adds a `https://developer.android.com/reference/android/graphics/drawable/Drawable` to the overlay. The bounds of the drawable should be relative to the host view. Any drawable added to the overlay should be removed when it is no longer needed or no longer visible. Adding an already existing `https://developer.android.com/reference/android/graphics/drawable/Drawable` is a no-op. Passing `null` parameter will result in an `https://developer.android.com/reference/java/lang/IllegalArgumentException` being thrown.

<br />

| Parameters ||
|---|---|
| `drawable` | `Drawable`: The `https://developer.android.com/reference/android/graphics/drawable/Drawable` to be added to the overlay. This drawable will be drawn when the view redraws its overlay. `https://developer.android.com/reference/android/graphics/drawable/Drawable`s will be drawn in the order that they were added. This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/ViewOverlay#remove(android.graphics.drawable.Drawable)`

### clear

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

```
public void clear ()
```

Removes all content from the overlay.

<br />

### remove

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

```
public void remove (Drawable drawable)
```

Removes the specified `https://developer.android.com/reference/android/graphics/drawable/Drawable` from the overlay. Removing a `https://developer.android.com/reference/android/graphics/drawable/Drawable` that was not added with `https://developer.android.com/reference/android/view/ViewOverlay#add(android.graphics.drawable.Drawable)` is a no-op. Passing `null` parameter will result in an `https://developer.android.com/reference/java/lang/IllegalArgumentException` being thrown.

<br />

| Parameters ||
|---|---|
| `drawable` | `Drawable`: The `https://developer.android.com/reference/android/graphics/drawable/Drawable` to be removed from the overlay. This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/ViewOverlay#add(android.graphics.drawable.Drawable)`