相关疑难解决方法(0)

RecyclerView - 如何在某个位置平滑滚动到项目顶部?

在RecyclerView上,我可以使用以下命令突然滚动到所选项目的顶部:

((LinearLayoutManager) recyclerView.getLayoutManager()).scrollToPositionWithOffset(position, 0);
Run Code Online (Sandbox Code Playgroud)

但是,这突然将项目移动到顶部位置.我想顺利地移动到项目的顶部.

我也尝试过:

recyclerView.smoothScrollToPosition(position);
Run Code Online (Sandbox Code Playgroud)

但它不能很好地工作,因为它不会将项目移动到选定的顶部位置.它只是滚动列表,直到位置上的项目可见.

android scroll position smooth android-recyclerview

100
推荐指数
7
解决办法
8万
查看次数

标签 统计

android ×1

android-recyclerview ×1

position ×1

scroll ×1

smooth ×1