Added in API level 18

ViewOverlay

open class ViewOverlay
kotlin.Any
   ↳ android.view.ViewOverlay

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 ViewGroupOverlay, which also supports adding and removing views.

Summary

Public methods
open Unit
add(drawable: Drawable)

Adds a Drawable to the overlay.

open Unit

Removes all content from the overlay.

open Unit
remove(drawable: Drawable)

Removes the specified Drawable from the overlay.

Public methods

add

Added in API level 18
open fun add(drawable: Drawable): Unit

Adds a 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 Drawable is a no-op. Passing null parameter will result in an IllegalArgumentException being thrown.

Parameters
drawable Drawable: The Drawable to be added to the overlay. This drawable will be drawn when the view redraws its overlay. Drawables will be drawn in the order that they were added. This value cannot be null.

clear

Added in API level 18
open fun clear(): Unit

Removes all content from the overlay.

remove

Added in API level 18
open fun remove(drawable: Drawable): Unit

Removes the specified Drawable from the overlay. Removing a Drawable that was not added with add(android.graphics.drawable.Drawable) is a no-op. Passing null parameter will result in an IllegalArgumentException being thrown.

Parameters
drawable Drawable: The Drawable to be removed from the overlay. This value cannot be null.

See Also