RecyclerView删除动画错误 [英] RecyclerView remove animation bug

查看:158
本文介绍了RecyclerView删除动画错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经实现了RecyclerView,可以在其中添加和删除项目.我希望将添加的项目添加到倒数第二个位置,并且每当添加新项目时,动画就会运行良好.也就是说,最后一项向下移动,从而使新项的空间逐渐淡入.

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. 淡出已删除的元素,
  2. 向上移动它下面的所有项目.

实际上发生的事情是,第一件事,最后一项消失了,然后动画的其余部分就发生了.当删除的元素下方的项目向上移动时,最后一个项目重新出现,因为它来自墙后.

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.

对我来说,好像RecyclerView缩小到动画后"高度,然后执行动画.

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

我还没有定义ItemAnimator,所以DefaultItemAnimator必须是使用的.我已经观看了此视频,并在LinearLayoutManager的自定义实现中覆盖了supportsPredictiveItemAnimations方法,但是它没有不能解决.

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.

推荐答案

我已经通过Google问题跟踪器报告了该问题

I already reported the problem through Google Issue Tracker here

我希望我们能尽快得到解决!就像您说的那样,当recyclerview包装内容以计算高度时,这似乎与recyclerview的小节更新和动画之间的可能竞赛条件非常相关.

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.

这篇关于RecyclerView删除动画错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆