```val id = if (isSelected) R.drawable.ic_btncheck...
# compose
u
Copy code
val id = if (isSelected) R.drawable.ic_btncheckboxon else R.drawable.ic_btncheckboxoff <-------------------- 
Image(
    modifier = Modifier
        .size(20.dp, 20.dp)
        .clickable { onClick() },
    painter = painterResource(id = id),
    contentDescription = null
)
how can I animate changing image resource?
m
Could have two calls to Image each in their own AnimatedVisibility calls.
e
depends on what kind of animation you want. wrap it in
AnimatedContent
for a simple transition. or convert both to a single AnimatedVectorDrawable wrapped in accompanist painter if you want to morph paths
u
AnimatedContent for transitioning between 2
Image
composables?
z
Crossfade
is an option too, it’s like a more limited
AnimatedContent
u
right but not for the painter resource itself but between 2 `Image`s?
z
Yes
Image
can’t do any animations itself
👍 1