To use an AnimatedVectorDrawable
resource, load up the drawable file using animatedVectorResource
and pass in a boolean
to switch between the start and end state of your drawable.
@Composable fun AnimatedVectorDrawable() { val image = AnimatedImageVector.animatedVectorResource(R.drawable.ic_hourglass_animated) var atEnd by remember { mutableStateOf(false) } Image( painter = rememberAnimatedVectorPainter(image, atEnd), contentDescription = "Timer", modifier = Modifier.clickable { atEnd = !atEnd }, contentScale = ContentScale.Crop ) }
For more information about the format of your drawable file, see Animate drawable graphics.