RecyclerView remove animation bug

前端 未结 2 1014
忘了有多久
忘了有多久 2021-02-15 15: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, th

相关标签:
2条回答
  • 2021-02-15 15:43

    Perhaps a bit late, but I was able to fix this in my situation by setting the RecyclerView item animator to null, and then in the setList(list) function of my Adapter scheduling a Transition as such:

    Transition transition = new AutoTransition();
    transition.setDuration(200); // Or any duration you want
    TransitionManager.beginDelayedTransition(mRootViewGroup, transition);
    

    where mRootViewGroup is the viewgroup containing the RecyclerView.

    This problem is also fixed by setting your layout_height (or width, depending on the scrolling orientation) to something other than wrap_content, but if, like me, you need your recyclerview height set to wrap_content, this might be a solution for you.

    Not certain it will fix your problem as well, but I figured I might as well share what worked for me.

    0 讨论(0)
  • 2021-02-15 15:58

    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.

    0 讨论(0)
提交回复
热议问题