RecyclerView.Adapter.notifyItemMoved(0,1) 滚动屏幕 [英] RecyclerView.Adapter.notifyItemMoved(0,1) scrolls screen

查看:58
本文介绍了RecyclerView.Adapter.notifyItemMoved(0,1) 滚动屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个由 LinearlayoutManager 管理的 RecyclerView,如果我用 0 交换项目 1 然后调用 mAdapter.notifyItemMoved(0,1),移动动画会导致屏幕滚动.我该如何预防?

I have a RecyclerView managed by a LinearlayoutManager, if I swap item 1 with 0 and then call mAdapter.notifyItemMoved(0,1), the moving animation causes the screen to scroll. How can I prevent it?

推荐答案

在移动项目后调用 scrollToPosition(0).不幸的是,我假设 LinearLayoutManager 试图保持第一个项目稳定,它移动所以它移动列表.

Call scrollToPosition(0) after moving items. Unfortunately, i assume, LinearLayoutManager tries to keep first item stable, which moves so it moves the list with it.

这篇关于RecyclerView.Adapter.notifyItemMoved(0,1) 滚动屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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