rememberAnimatedVectorPainter
Creates and remembers a [Painter] to render an [AnimatedImageVector]. It renders the image either
rememberAnimatedVectorPainter
Composable Function
Android
@Composable
public fun rememberAnimatedVectorPainter(
animatedImageVector: AnimatedImageVector,
atEnd: Boolean,
): Painter
Creates and remembers a Painter to render an AnimatedImageVector. It renders the image either
at the start or the end of all the animations depending on the atEnd. Changes to atEnd are
animated.
Parameters
animatedImageVector | An AnimatedImageVector object to be remembered and animated. |
| atEnd | Whether the animated vector should be rendered at the end of all its animations. |
Code Examples
AnimatedVectorSample
@Composable
fun AnimatedVectorSample() {
@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 },
)
}
}
