# rememberAnimatedVectorPainter

## Functions summary

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/painter/Painter` | `@https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable https://developer.android.com/reference/kotlin/androidx/compose/animation/graphics/res/rememberAnimatedVectorPainter.composable#rememberAnimatedVectorPainter(androidx.compose.animation.graphics.vector.AnimatedImageVector,kotlin.Boolean)( animatedImageVector: https://developer.android.com/reference/kotlin/androidx/compose/animation/graphics/vector/AnimatedImageVector, atEnd: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Creates and remembers a `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/painter/Painter` to render an `https://developer.android.com/reference/kotlin/androidx/compose/animation/graphics/vector/AnimatedImageVector`. |

## Functions

### rememberAnimatedVectorPainter

Artifact: [androidx.compose.animation:animation-graphics](https://developer.android.com/jetpack/androidx/releases/compose-animation) [View Source](https://cs.android.com/search?q=file:androidx/compose/animation/graphics/res/AnimatedVectorPainterResources.android.kt+function:rememberAnimatedVectorPainter)

```
@Composable
fun rememberAnimatedVectorPainter(
    animatedImageVector: AnimatedImageVector,
    atEnd: Boolean
): Painter
```

Creates and remembers a `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/painter/Painter` to render an `https://developer.android.com/reference/kotlin/androidx/compose/animation/graphics/vector/AnimatedImageVector`. It renders the image either at the start or the end of all the animations depending on the `https://developer.android.com/reference/kotlin/androidx/compose/animation/graphics/res/package-summary#rememberAnimatedVectorPainter(androidx.compose.animation.graphics.vector.AnimatedImageVector,kotlin.Boolean)`. Changes to `https://developer.android.com/reference/kotlin/androidx/compose/animation/graphics/res/package-summary#rememberAnimatedVectorPainter(androidx.compose.animation.graphics.vector.AnimatedImageVector,kotlin.Boolean)` are animated.

```kotlin
import androidx.annotation.DrawableRes
import androidx.compose.animation.graphics.ExperimentalAnimationGraphicsApi
import androidx.compose.animation.graphics.res.animatedVectorResource
import androidx.compose.animation.graphics.res.rememberAnimatedVectorPainter
import androidx.compose.animation.graphics.vector.AnimatedImageVector
import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp

@OptIn(ExperimentalAnimationGraphicsApi::class)
@Composable
fun AnimatedVector(@DrawableRes drawableId: Int) {
    val image = AnimatedImageVector.animatedVectorResource(drawableId)
    var atEnd by remember { mutableStateOf(false) }
    Image(
        painter = rememberAnimatedVectorPainter(image, atEnd),
        contentDescription = "Your content description",
        modifier = Modifier.size(64.dp).clickable { atEnd = !atEnd },
    )
}
```

| Parameters |
|---|---|
| `animatedImageVector: https://developer.android.com/reference/kotlin/androidx/compose/animation/graphics/vector/AnimatedImageVector` | An `https://developer.android.com/reference/kotlin/androidx/compose/animation/graphics/vector/AnimatedImageVector` object to be remembered and animated. |
| `atEnd: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the animated vector should be rendered at the end of all its animations. |