HI , I have a list of items in lazy column view. ...
# compose
a
HI , I have a list of items in lazy column view. How we can show animation when we are removing the one item from the list. I need to animate the view which is getting deleted. The delete operation is done by pressing the delete icon inside the view.
s
I guess you could wrap your list item inside AnimatedVisibility
a
Yes, But item is not animating when its getting deleted. I have added the enter and exit animation to the AnimatedVisibility
y
I think I replied to this question on StackOverflow, did you try that method?
a
Yes, But animation is not working when item is removed.
y
Rip - I dont have any more ideas then, that sounded like the only possible way for now
a
I tried with removing item from the list. Are you saying its showing the animatino based on a value without removing it from the list ?
y
I havent tried implementing it myself so I am not sure if itll work or not but let me try to explain it simpler
1 - Once an item is removed, instead of removing it from the list you just set a
removed
boolean variable to true in the item. 2 - Your composable list updates and shows the same number of items. You can now hide the
removed
items with animation. 3 - Once the animation is over you can update your list without the
removed
items
Although I am pretty sure this wont result in a smooth animation anyways
a
So do we need to map the boolean variable to the list item ?.
y
yes
a
when im doing that two items are getting removed
d
YASAN's 3-step suggestion sums it up well. 🙂 The important thing is to retain the removed item during the removal animation (i.e. not delete the item right away). Here's an example that covers the first 2 steps: https://github.com/Gurupreet/ComposeCookBook/blob/e067635ac0211e9c59a1e9d638d55ee0[…]va/com/guru/composecookbook/ui/demoapps/gmail/home/GmailHome.kt
✔️ 1
n
@Ajay Venugopal I found a solution… maybe not the best one, but it’s working…
m
@nglauber what did you end up doing ? I'm facing the same issue