(平滑)ScrollToPosition无法与RecyclerView一起正常使用 [英] (Smooth)ScrollToPosition doesn't work properly with RecyclerView

查看:509
本文介绍了(平滑)ScrollToPosition无法与RecyclerView一起正常使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将基本的RecyclerView与GridLayoutManager一起使用.我观察到smoothScrollToPosition和scrollToPosition都无法正常工作.

a)使用smoothScrollToPosition时,我经常收到RecyclerView

的错误消息

"RecyclerView:平滑滚动时越过了目标位置."

RecyclerView滚动不正确(通常会错过目标行).当我尝试滚动到某行的第一项时,通常会观察到这种情况

b)使用scrollToPosition时似乎可以正常工作,但是大多数时候我只能看到该行的第一项,其余的都不会显示.

您能给我一些如何使至少一种方法正常工作的提示吗?

非常感谢!

解决方案

最后,我能够使其工作! LinearLayoutManager.scrollToPositionWithOffset(int, int) 达到了目的./p>

I'm using basic RecyclerView with GridLayoutManager. I observed that nor smoothScrollToPosition nor scrollToPosition works properly.

a) when using smoothScrollToPosition I often receive error from RecyclerView

"RecyclerView﹕ Passed over target position while smooth scrolling."

and RecyclerView is not scrolled properly (often it misses the targeted row). This is observed mostly when I'm trying to scroll to the 1st item of some row

b) when using scrollToPosition it seems to work quite ok but most of the time I can see only the 1st item of the row and the rest are not displayed.

Can you give me some hints how to make work properly at least one of the methods?

Thanks a lot!

解决方案

Finally I was able to make it work! LinearLayoutManager.scrollToPositionWithOffset(int, int) did the trick.

这篇关于(平滑)ScrollToPosition无法与RecyclerView一起正常使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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