RecyclerView remove animation bug

。_饼干妹妹 提交于 2019-12-04 22:02:26

问题


I have implemented a RecyclerView where I can add and delete items. I want the added item to be added on the second last position and, whenever I add a new item, the animation runs well. That is, the last item moves downwards, letting space for the new item to fade in.

When I remove an item there is a problem that I don't know how to fix. How I want it to behave is:

  1. fade out the deleted element,
  2. move upwards all the items below it.

What actually happens is that, first thing, the last item disappears, and then the rest of the animation takes place. When the items below the deleted element move upwards, the last item reappears as coming from behind a wall.

To me it seems as if the RecyclerView shrinks to the "post-animation" height, and then the animation is performed.

I haven't defined the ItemAnimator, so the DefaultItemAnimator must be the one used. I have watched this video, and overridden the supportsPredictiveItemAnimations method in a custom implementation of LinearLayoutManager, but it doesn't fix it.


回答1:


I already reported the problem through Google Issue Tracker here

I hope we can get a fix soon! As you say It seems very related to a possible race condition between the measure updates for the recyclerview and the animation when your recyclerview is wrapping it's content to calculate it's height.

This article explains the problem in a really detailed way also.



来源:https://stackoverflow.com/questions/36117070/recyclerview-remove-animation-bug

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!