Hey guys, I have a animated resource that i am try...
# multiplatform
k
Hey guys, I have a animated resource that i am trying to display in compose-multiplatform but my app keeps crashing whenever it reaches the stage of rendering the resource, in android I would do this
Copy code
@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
    )
}
in commonMain i tried this but the
id, property
that animatedVectorResource is trying to identify is not present in the Res.drawable.ic_hourglass_animated
m
Not sure if animated vector drawables are supported with the current Resource api? I would say not yet
k
I visited the docs as well as experimental apis and it doesn't seem to support it yet. Do you have any work arounds for animating vector drawables?
m
@Kambi Victor Since XML drawables are a very specific format for animation, i’d say there is no way currently. You could rebuild the animation in pure compose, or use a Lottie. There are Lottie libs out there afaik for CMP. Personally, i try to minimize 3rd party usage, to minimize build breakage when KMP/CMP will be upgraded. So personally i would try to use pure compose
k
@Max I plan on using pure compose for this. Thanks for the suggestion.
👍 1