2

How, to attain animation like we get in DiffUtil RecyclerView when new items are added to the list?

I've a LazyColumn with multiple items as composables. Each composable are different. My code looks like this:

LazyColumn{
    item{
        ChipGroup()
    }
    viewModel.list.forEach{
        item{
            ListItem()
        }
    }
    item{
        ContinueButton()
    }
    .
    .
    .
}

So, How to attain a simple animation like we get as default in DiffUtil RecyclerView when each time viewModel.list gets a new item added?

Phil Dukhov
  • 67,741
  • 15
  • 184
  • 220
imn
  • 620
  • 1
  • 7
  • 19
  • check out [this answer](https://stackoverflow.com/a/68928544/3585796) – Phil Dukhov Sep 05 '21 at 04:42
  • when scrolling ,animation is playing because launched effect is triggering when item comes to foreground. is there any way to solve this? thanks! – imn Sep 06 '21 at 18:24
  • Oh yes, I think, as I said in that reply, you should wait for official support. You could try tracking added items with `LaunchedEffect` + `remember`, but if it were that easy to implement, I think it would already be official=) – Phil Dukhov Sep 07 '21 at 06:05
  • Checkout this answer: https://stackoverflow.com/questions/72537949/jetpack-compose-lazy-column-insertion-and-deletion-animations-with-multiple-item/72537950#72537950 – Charles Woodson Jun 07 '22 at 22:00

0 Answers0