Vas*_*sia 6 android android-recyclerview
我RecyclerView用LinearLayoutManager(Vertical不倒).当我将项目插入或移动到0位置时,会调用此方法:
private void scrollToStart() {
int firstVisiblePosition = ((LinearLayoutManager) recentList.getLayoutManager()).findFirstCompletelyVisibleItemPosition();
boolean notScrolling = recentList.getScrollState() == RecyclerView.SCROLL_STATE_IDLE;
if (firstVisiblePosition < 2 && notScrolling) {
recentList.scrollToPosition(0);
}
}
Run Code Online (Sandbox Code Playgroud)
但有时它会平滑滚动到列表的末尾.
(我在Instagram等应用程序中看到过这样的行为.看起来列表滚动到顶部然后开始向相反的方向移动.)
如果我smoothScrollToPosition用simple 替换scrollToPosition它,它的行为应该如此.
如何防止此滚动?