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

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

问题描述

我有一个由LinearlayoutManager管理的RecyclerView,如果我将项目1与0交换,然后调用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天全站免登陆