Stay organized with collections
Save and categorize content based on your preferences.
ViewOverlay
open class ViewOverlay
Known Direct Subclasses
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 ViewGroupOverlay
, which also supports adding and removing views.
Summary
Public methods |
open Unit |
Adds a Drawable to the overlay.
|
open Unit |
Removes all content from the overlay.
|
open Unit |
Removes the specified Drawable from the overlay.
|
Public methods
add
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. Drawable s will be drawn in the order that they were added. This value cannot be null . |
clear
open fun clear(): Unit
Removes all content from the overlay.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# ViewOverlay\n\nAdded in [API level 18](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nViewOverlay\n===========\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/view/ViewOverlay \"View this page in Java\") \n\n```\nopen class ViewOverlay\n```\n\n|---|-------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.view.ViewOverlay](#) |\n\n|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Known Direct Subclasses [ViewGroupOverlay](/reference/kotlin/android/view/ViewGroupOverlay) |---------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [ViewGroupOverlay](/reference/kotlin/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). | |\n\nAn 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.\n\nAn overlay requested from a ViewGroup is of type [ViewGroupOverlay](/reference/kotlin/android/view/ViewGroupOverlay), which also supports adding and removing views.\n\nSummary\n-------\n\n| Public methods ||\n|-----------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [add](#add(android.graphics.drawable.Drawable))`(`drawable:` `[Drawable](../graphics/drawable/Drawable.html#)`)` Adds a [Drawable](../graphics/drawable/Drawable.html#) to the overlay. |\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [clear](#clear())`()` Removes all content from the overlay. |\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [remove](#remove(android.graphics.drawable.Drawable))`(`drawable:` `[Drawable](../graphics/drawable/Drawable.html#)`)` Removes the specified [Drawable](../graphics/drawable/Drawable.html#) from the overlay. |\n\nPublic methods\n--------------\n\n### add\n\nAdded in [API level 18](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun add(drawable: Drawable): Unit\n```\n\nAdds a [Drawable](../graphics/drawable/Drawable.html#) 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](../graphics/drawable/Drawable.html#) is a no-op. Passing `null` parameter will result in an [IllegalArgumentException](../../java/lang/IllegalArgumentException.html#) being thrown.\n\n| Parameters ||\n|------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `drawable` | [Drawable](../graphics/drawable/Drawable.html#): The [Drawable](../graphics/drawable/Drawable.html#) to be added to the overlay. This drawable will be drawn when the view redraws its overlay. [Drawable](../graphics/drawable/Drawable.html#)s will be drawn in the order that they were added. This value cannot be `null`. |\n\n**See Also**\n\n- [#remove(Drawable)](#remove(android.graphics.drawable.Drawable)) \n\n### clear\n\nAdded in [API level 18](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun clear(): Unit\n```\n\nRemoves all content from the overlay. \n\n### remove\n\nAdded in [API level 18](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun remove(drawable: Drawable): Unit\n```\n\nRemoves the specified [Drawable](../graphics/drawable/Drawable.html#) from the overlay. Removing a [Drawable](../graphics/drawable/Drawable.html#) that was not added with [add(android.graphics.drawable.Drawable)](#add(android.graphics.drawable.Drawable)) is a no-op. Passing `null` parameter will result in an [IllegalArgumentException](../../java/lang/IllegalArgumentException.html#) being thrown.\n\n| Parameters ||\n|------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `drawable` | [Drawable](../graphics/drawable/Drawable.html#): The [Drawable](../graphics/drawable/Drawable.html#) to be removed from the overlay. This value cannot be `null`. |\n\n**See Also**\n\n- [#add(Drawable)](#add(android.graphics.drawable.Drawable))"]]