我正在使用带有 GridLayoutManager 的基本 RecyclerView.我观察到 smoothScrollToPosition 和 scrollToPosition 都不能正常工作.
I'm using basic RecyclerView with GridLayoutManager. I observed that nor smoothScrollToPosition nor scrollToPosition works properly.
a) 使用 smoothScrollToPosition 时,我经常收到来自 RecyclerView
a) when using smoothScrollToPosition I often receive error from RecyclerView
RecyclerView:平滑滚动时越过目标位置."
"RecyclerView﹕ Passed over target position while smooth scrolling."
和 RecyclerView 未正确滚动(通常会错过目标行).这主要是在我尝试滚动到某行的第一项时观察到的
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) 当使用 scrollToPosition 时,它似乎工作得很好,但大多数时候我只能看到该行的第 1 项,其余的都没有显示.
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?
非常感谢!
推荐答案我终于能够让它工作了!LinearLayoutManager.scrollToPositionWithOffset(int, int) 成功了.
Finally I was able to make it work! LinearLayoutManager.scrollToPositionWithOffset(int, int) did the trick.
更多推荐
(Smooth)ScrollToPosition 不能与 RecyclerView 一起正常工作
发布评论