# Animatable2Compat

# Animatable2Compat

Artifact:[androidx.vectordrawable:vectordrawable-animated](https://developer.android.com/jetpack/androidx/releases/vectordrawable)  
[View Source](https://cs.android.com/search?q=file:androidx/vectordrawable/graphics/drawable/Animatable2Compat.java+class:androidx.vectordrawable.graphics.drawable.Animatable2Compat)  
Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/vectordrawable#1.0.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/vectordrawable/graphics/drawable/Animatable2Compat "View this page in Java")

<br />

```
interface Animatable2Compat : Animatable
```

<br />

Known direct subclasses  
[AnimatedVectorDrawableCompat](https://developer.android.com/reference/kotlin/androidx/vectordrawable/graphics/drawable/AnimatedVectorDrawableCompat)  

|-------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [AnimatedVectorDrawableCompat](https://developer.android.com/reference/kotlin/androidx/vectordrawable/graphics/drawable/AnimatedVectorDrawableCompat) | For API 24 and above, this class is delegating to the framework's[AnimatedVectorDrawable](https://developer.android.com/reference/android/graphics/drawable/AnimatedVectorDrawable.html). |

*** ** * ** ***

Interface that drawables supporting animations and callbacks should extend in support lib.

## Summary

|                                                                                                      ### Nested types                                                                                                       |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `abstract class `[Animatable2Compat.AnimationCallback](https://developer.android.com/reference/kotlin/androidx/vectordrawable/graphics/drawable/Animatable2Compat.AnimationCallback) Abstract class for animation callback. |

|                                ### Public functions                                 |
|-------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)       | [clearAnimationCallbacks](https://developer.android.com/reference/kotlin/androidx/vectordrawable/graphics/drawable/Animatable2Compat#clearAnimationCallbacks())`()` Removes all existing animation callbacks.                                                                                                                                                                                                                                                                               |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)       | [registerAnimationCallback](https://developer.android.com/reference/kotlin/androidx/vectordrawable/graphics/drawable/Animatable2Compat#registerAnimationCallback(androidx.vectordrawable.graphics.drawable.Animatable2Compat.AnimationCallback))`(` ` callback: `[Animatable2Compat.AnimationCallback](https://developer.android.com/reference/kotlin/androidx/vectordrawable/graphics/drawable/Animatable2Compat.AnimationCallback) `)` Adds a callback to listen to the animation events. |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | [unregisterAnimationCallback](https://developer.android.com/reference/kotlin/androidx/vectordrawable/graphics/drawable/Animatable2Compat#unregisterAnimationCallback(androidx.vectordrawable.graphics.drawable.Animatable2Compat.AnimationCallback))`(` ` callback: `[Animatable2Compat.AnimationCallback](https://developer.android.com/reference/kotlin/androidx/vectordrawable/graphics/drawable/Animatable2Compat.AnimationCallback) `)` Removes the specified animation callback.      |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                      ### Inherited functions                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From[android.graphics.drawable.Animatable](https://developer.android.com/reference/android/graphics/drawable/Animatable.html) |-------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------| | [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | [isRunning](https://developer.android.com/reference/android/graphics/drawable/Animatable.html#isRunning())`()` | | [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)       | [start](https://developer.android.com/reference/android/graphics/drawable/Animatable.html#start())`()`         | | [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)       | [stop](https://developer.android.com/reference/android/graphics/drawable/Animatable.html#stop())`()`           | |

## Public functions

### clearAnimationCallbacks

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/vectordrawable#1.0.0)  

```
fun clearAnimationCallbacks(): Unit
```

Removes all existing animation callbacks.  

### registerAnimationCallback

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/vectordrawable#1.0.0)  

```
fun registerAnimationCallback(
    callback: Animatable2Compat.AnimationCallback
): Unit
```

Adds a callback to listen to the animation events.  

|                                                                                   Parameters                                                                                    |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------|
| `callback: `[Animatable2Compat.AnimationCallback](https://developer.android.com/reference/kotlin/androidx/vectordrawable/graphics/drawable/Animatable2Compat.AnimationCallback) | Callback to add. |

### unregisterAnimationCallback

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/vectordrawable#1.0.0)  

```
fun unregisterAnimationCallback(
    callback: Animatable2Compat.AnimationCallback
): Boolean
```

Removes the specified animation callback.  

|                                                                                   Parameters                                                                                    |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------|
| `callback: `[Animatable2Compat.AnimationCallback](https://developer.android.com/reference/kotlin/androidx/vectordrawable/graphics/drawable/Animatable2Compat.AnimationCallback) | Callback to remove. |

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | `false`if callback didn't exist in the call back list, or`true`if callback has been removed successfully. |