I have an animated-vector that I want to change the speed dynamically in jetpack compose, here is what I have at the moment.your text
I’m using the LaunchedEffect in order to loop the animation, and currently it works for looping, but now I want a way to change the animation speed.I tried to change the delay value, with different approach but it cut off the animation in whenever I change the speed to for example (animation.totalDuration * 0.8).toLong()
@OptIn(ExperimentalAnimationGraphicsApi::class)
@Composable
fun Greeting(modifier: Modifier = Modifier) {
var atEnd by remember { mutableStateOf(false) }
val animation = AnimatedImageVector.animatedVectorResource(id = R.drawable.my_animation2)
val painterFirst = rememberAnimatedVectorPainter(
animatedImageVector = animation,
atEnd = atEnd
)
LaunchedEffect(Unit) {
while (true) {
atEnd = !atEnd
delay(animation.totalDuration.toLong())
}
}
Column {
Image(painter = painterFirst, contentDescription = "null")
}
}
Owen Yamil Sahagun Ortega is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.