Hi, anyone using `AnimatedVisibility`? I'm using t...
# compose
s
Hi, anyone using
AnimatedVisibility
? I'm using this to create an expand and contract animation in a column with a list of items that have a small image and text. I'm getting a very laggy unresponsive layout in the expansion animation when the layout has images. If I remove the images the animations run smoothly. I've tried
remember
to save the bitmap,
derivedStateOf
, Coil
AsynImage,
loading from the ViewModel, and other tricks but still a column inside
nimatedVisibility
with a list of images is super SLOW. What can be done to make the animation smoother?
e
Have you tried with a release build?
d
Generally I do not animate an entire list. I have only made the items in the list individually animated.
s
Yes I've tried release build. but till when clicking to expand there is a delay blocking the entire UI, no animation and then all the list with the images appear in place.
How do you do that Eric? expand and collapse each item?
d
How do you do that Eric? expand and collapse each item?
Yes I have each item be wrapped in the
AnimatedVisibility
Composable and then drive it via boolean on a State class I pass in. For example:
Copy code
data class MyItemUiState(val isVisible: Boolean, ...)

@Composable
fun MyItem(state: MyItemUiState, ...) {
  AnimatedVisisbility(state.isVisible) {
    Row() {
      ....
    }
  }
}
Note you could also make a stateless version too.