# AnimatorInflater

# AnimatorInflater

Artifact:[androidx.core:core-animation](https://developer.android.com/jetpack/androidx/releases/core)  
[View Source](https://cs.android.com/search?q=file:androidx/core/animation/AnimatorInflater.java+class:androidx.core.animation.AnimatorInflater)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/core/animation/AnimatorInflater "View this page in Java")

<br />

```
class AnimatorInflater
```

<br />

*** ** * ** ***

This class is used to instantiate animator XML files into Animator objects.

For performance reasons, inflation relies heavily on pre-processing of XML files that is done at build time. Therefore, it is not currently possible to use this inflater with an XmlPullParser over a plain XML file at runtime; it only works with an XmlPullParser returned from a compiled resource (R.*something*file.)

## Summary

|                                               ### Public functions                                                |
|-------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `java-static `[Animator](https://developer.android.com/reference/kotlin/androidx/core/animation/Animator)         | [loadAnimator](https://developer.android.com/reference/kotlin/androidx/core/animation/AnimatorInflater#loadAnimator(android.content.Context,int))`(context: `[Context](https://developer.android.com/reference/android/content/Context.html)`, id: @`[AnimatorRes](https://developer.android.com/reference/kotlin/androidx/annotation/AnimatorRes)` `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Loads an[Animator](https://developer.android.com/reference/kotlin/androidx/core/animation/Animator)object from a resource                                                                                                                                                                               |
| `java-static `[Animator](https://developer.android.com/reference/kotlin/androidx/core/animation/Animator)         | [loadAnimator](https://developer.android.com/reference/kotlin/androidx/core/animation/AnimatorInflater#loadAnimator(android.content.res.Resources,android.content.res.Resources.Theme,int))`(` ` resources: `[Resources](https://developer.android.com/reference/android/content/res/Resources.html)`,` ` theme: `[Resources.Theme](https://developer.android.com/reference/android/content/res/Resources.Theme.html)`?,` ` id: @`[AnimatorRes](https://developer.android.com/reference/kotlin/androidx/annotation/AnimatorRes)` `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) `)` Loads an[Animator](https://developer.android.com/reference/kotlin/androidx/core/animation/Animator)object from a resource |
| `java-static `[Interpolator](https://developer.android.com/reference/kotlin/androidx/core/animation/Interpolator) | [loadInterpolator](https://developer.android.com/reference/kotlin/androidx/core/animation/AnimatorInflater#loadInterpolator(android.content.Context,int))`(context: `[Context](https://developer.android.com/reference/android/content/Context.html)`, id: @`[AnimatorRes](https://developer.android.com/reference/kotlin/androidx/annotation/AnimatorRes)` @`[InterpolatorRes](https://developer.android.com/reference/kotlin/androidx/annotation/InterpolatorRes)` `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Loads an[Interpolator](https://developer.android.com/reference/kotlin/androidx/core/animation/Interpolator)object from a resource                                                      |

## Public functions

### loadAnimator

```
java-static fun loadAnimator(context: Context, id: @AnimatorRes Int): Animator
```

Loads an[Animator](https://developer.android.com/reference/kotlin/androidx/core/animation/Animator)object from a resource  

|                                                                                     Parameters                                                                                     |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------|
| `context: `[Context](https://developer.android.com/reference/android/content/Context.html)                                                                                         | Application context used to access resources |
| `id: @`[AnimatorRes](https://developer.android.com/reference/kotlin/androidx/annotation/AnimatorRes)` `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The resource id of the animation to load     |

|                                           Returns                                           |
|---------------------------------------------------------------------------------------------|---------------------------------------------------|
| [Animator](https://developer.android.com/reference/kotlin/androidx/core/animation/Animator) | The animator object reference by the specified id |

|                                                                     Throws                                                                      |
|-------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------|
| [android.content.res.Resources.NotFoundException](https://developer.android.com/reference/android/content/res/Resources.NotFoundException.html) | when the animation cannot be loaded |

### loadAnimator

```
java-static fun loadAnimator(
    resources: Resources,
    theme: Resources.Theme?,
    id: @AnimatorRes Int
): Animator
```

Loads an[Animator](https://developer.android.com/reference/kotlin/androidx/core/animation/Animator)object from a resource  

|                                                                                     Parameters                                                                                     |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------|
| `resources: `[Resources](https://developer.android.com/reference/android/content/res/Resources.html)                                                                               | The resources                            |
| `theme: `[Resources.Theme](https://developer.android.com/reference/android/content/res/Resources.Theme.html)`?`                                                                    | The theme                                |
| `id: @`[AnimatorRes](https://developer.android.com/reference/kotlin/androidx/annotation/AnimatorRes)` `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The resource id of the animation to load |

|                                           Returns                                           |
|---------------------------------------------------------------------------------------------|---------------------------------------------------|
| [Animator](https://developer.android.com/reference/kotlin/androidx/core/animation/Animator) | The animator object reference by the specified id |

|                                                                     Throws                                                                      |
|-------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------|
| [android.content.res.Resources.NotFoundException](https://developer.android.com/reference/android/content/res/Resources.NotFoundException.html) | when the animation cannot be loaded |

### loadInterpolator

```
java-static fun loadInterpolator(context: Context, id: @AnimatorRes @InterpolatorRes Int): Interpolator
```

Loads an[Interpolator](https://developer.android.com/reference/kotlin/androidx/core/animation/Interpolator)object from a resource  

|                                                                                                                                         Parameters                                                                                                                                          |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------|
| `context: `[Context](https://developer.android.com/reference/android/content/Context.html)                                                                                                                                                                                                  | Application context used to access resources |
| `id: @`[AnimatorRes](https://developer.android.com/reference/kotlin/androidx/annotation/AnimatorRes)` @`[InterpolatorRes](https://developer.android.com/reference/kotlin/androidx/annotation/InterpolatorRes)` `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The resource id of the animation to load     |

|                                               Returns                                               |
|-----------------------------------------------------------------------------------------------------|----------------------------------------------------|
| [Interpolator](https://developer.android.com/reference/kotlin/androidx/core/animation/Interpolator) | The animation object reference by the specified id |

|                                                                     Throws                                                                      |
|-------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------|
| [android.content.res.Resources.NotFoundException](https://developer.android.com/reference/android/content/res/Resources.NotFoundException.html) | when interpolator resources cannot be loaded |