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/ViewGroupOverlay#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/view/ViewGroupOverlay#inhmethods)

# ViewGroupOverlay

*** ** * ** ***

` public class ViewGroupOverlay `   
` ` ` extends https://developer.android.com/reference/android/view/ViewOverlay ` ` `

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

<br />

*** ** * ** ***

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). Interaction with the overlay layer is done by adding and removing views and drawables.

ViewGroupOverlay is a subclass of `https://developer.android.com/reference/android/view/ViewOverlay`, adding the ability to manage views for overlays on ViewGroups, in addition to the drawable support in ViewOverlay.

<br />

**See also:**

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

## Summary

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/view/ViewGroupOverlay#add(android.view.View)(https://developer.android.com/reference/android/view/View view) ` Adds a `View` to the overlay. |
| ` void` | ` https://developer.android.com/reference/android/view/ViewGroupOverlay#remove(android.view.View)(https://developer.android.com/reference/android/view/View view) ` Removes the specified `View` from the overlay. |

### Inherited methods

From class ` https://developer.android.com/reference/android/view/ViewOverlay ` ` 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.
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 (View view)
```

Adds a `View` to the overlay. The bounds of the added view should be relative to the host view. Any view added to the overlay should be removed when it is no longer needed or no longer visible.

Views in the overlay are visual-only; they do not receive input events and do not participate in focus traversal. Overlay views are intended to be transient, such as might be needed by a temporary animation effect.

If the view has a parent, the view will be removed from that parent before being added to the overlay. Also, if that parent is attached in the current view hierarchy, the view will be repositioned such that it is in the same relative location inside the activity. For example, if the view's current parent lies 100 pixels to the right and 200 pixels down from the origin of the overlay's host view, then the view will be offset by (100, 200).

`View`s added with this API will be drawn in the order they were added. Drawing of the overlay views will happen before drawing of any of the `Drawable`s added with `https://developer.android.com/reference/android/view/ViewOverlay#add(android.graphics.drawable.Drawable)` API even if a call to this API happened after the call to `https://developer.android.com/reference/android/view/ViewOverlay#add(android.graphics.drawable.Drawable)`.

Passing `null` parameter will result in an `https://developer.android.com/reference/java/lang/IllegalArgumentException` being thrown.

<br />

<br />

| Parameters ||
|---|---|
| `view` | `View`: The `View` to be added to the overlay. The added view will be drawn when the overlay is drawn. This value cannot be `null`. <br /> |

**See also:**

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

### remove

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

```
public void remove (View view)
```

Removes the specified `View` from the overlay. Passing `null` parameter will result in an `https://developer.android.com/reference/java/lang/IllegalArgumentException` being thrown.

<br />

| Parameters ||
|---|---|
| `view` | `View`: The `View` to be removed from the overlay. This value cannot be `null`. <br /> |

**See also:**

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