(平滑)ScrollToPosition无法与RecyclerView一起正常使用 [英] (Smooth)ScrollToPosition doesn't work properly with 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屋!