Stay organized with collections
Save and categorize content based on your preferences.
Animatable2
interface Animatable2 : Animatable
Abstract class that drawables supporting animations and callbacks should extend.
Summary
Public methods |
abstract Unit |
Removes all existing animation callbacks.
|
abstract Unit |
Adds a callback to listen to the animation events.
|
abstract Boolean |
Removes the specified animation callback.
|
Public methods
clearAnimationCallbacks
abstract fun clearAnimationCallbacks(): Unit
Removes all existing animation callbacks.
unregisterAnimationCallback
abstract fun unregisterAnimationCallback(callback: Animatable2.AnimationCallback): Boolean
Removes the specified animation callback.
Return |
Boolean |
false if callback didn't exist in the call back list, or true if callback has been removed successfully. |
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.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# Animatable2\n\nAdded in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nAnimatable2\n===========\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/graphics/drawable/Animatable2 \"View this page in Java\") \n\n```\ninterface Animatable2 : Animatable\n```\n\n|--------------------------------------------|\n| [android.graphics.drawable.Animatable2](#) |\n\n|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Known Direct Subclasses [AnimatedImageDrawable](/reference/kotlin/android/graphics/drawable/AnimatedImageDrawable), [AnimatedVectorDrawable](/reference/kotlin/android/graphics/drawable/AnimatedVectorDrawable) |----------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [AnimatedImageDrawable](/reference/kotlin/android/graphics/drawable/AnimatedImageDrawable) | [Drawable](/reference/kotlin/android/graphics/drawable/Drawable) for drawing animated images (like GIF). | | [AnimatedVectorDrawable](/reference/kotlin/android/graphics/drawable/AnimatedVectorDrawable) | This class animates properties of a [android.graphics.drawable.VectorDrawable](/reference/kotlin/android/graphics/drawable/VectorDrawable) with animations defined using [android.animation.ObjectAnimator](../../animation/ObjectAnimator.html#) or [android.animation.AnimatorSet](../../animation/AnimatorSet.html#). | |\n\nAbstract class that drawables supporting animations and callbacks should extend.\n\nSummary\n-------\n\n| Nested classes ||\n|----------|-------------------------------------------------------------------------------------------------------|\n| abstract | [AnimationCallback](/reference/kotlin/android/graphics/drawable/Animatable2.AnimationCallback) \u003cbr /\u003e |\n\n| Public methods ||\n|---------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [clearAnimationCallbacks](#clearAnimationCallbacks())`()` Removes all existing animation callbacks. |\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [registerAnimationCallback](#registerAnimationCallback(android.graphics.drawable.Animatable2.AnimationCallback))`(`callback:` `[Animatable2.AnimationCallback](/reference/kotlin/android/graphics/drawable/Animatable2.AnimationCallback)`)` Adds a callback to listen to the animation events. |\n| abstract [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [unregisterAnimationCallback](#unregisterAnimationCallback(android.graphics.drawable.Animatable2.AnimationCallback))`(`callback:` `[Animatable2.AnimationCallback](/reference/kotlin/android/graphics/drawable/Animatable2.AnimationCallback)`)` Removes the specified animation callback. |\n\n| Inherited functions ||\n|---|---|\n| From class [Animatable](/reference/kotlin/android/graphics/drawable/Animatable) |------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------| | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [isRunning](/reference/kotlin/android/graphics/drawable/Animatable#isRunning())`()` Indicates whether the animation is running. \u003cbr /\u003e | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [start](/reference/kotlin/android/graphics/drawable/Animatable#start())`()` Starts the drawable's animation. \u003cbr /\u003e | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [stop](/reference/kotlin/android/graphics/drawable/Animatable#stop())`()` Stops the drawable's animation. \u003cbr /\u003e | ||\n\nPublic methods\n--------------\n\n### clearAnimationCallbacks\n\nAdded in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun clearAnimationCallbacks(): Unit\n```\n\nRemoves all existing animation callbacks. \n\n### registerAnimationCallback\n\nAdded in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun registerAnimationCallback(callback: Animatable2.AnimationCallback): Unit\n```\n\nAdds a callback to listen to the animation events.\n\n| Parameters ||\n|------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `callback` | [Animatable2.AnimationCallback](/reference/kotlin/android/graphics/drawable/Animatable2.AnimationCallback): Callback to add. This value cannot be `null`. |\n\n### unregisterAnimationCallback\n\nAdded in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun unregisterAnimationCallback(callback: Animatable2.AnimationCallback): Boolean\n```\n\nRemoves the specified animation callback.\n\n| Parameters ||\n|------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `callback` | [Animatable2.AnimationCallback](/reference/kotlin/android/graphics/drawable/Animatable2.AnimationCallback): Callback to remove. This value cannot be `null`. |\n\n| Return ||\n|------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------|\n| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `false` if callback didn't exist in the call back list, or `true` if callback has been removed successfully. |"]]