使用 LinelayoutManager.scrollToPositionWithOffset 时如何让项目滚动到 Recycleview 的顶部?第一次无效

how to let item scroll to top of the Recycleview when using LinelayoutManager.scrollToPositionWithOffset?first time not effect

我想通过单击一次让 recycleview 项目滚动到顶部 button.and 我使用 lineLayoutManger.scrollToPositionWithOffset(position,0); 位置是当我进入 Activity 时我想滚动项目 postion.but 并在我单击按钮让第五项滚动到顶部时初始化 adapter.but 。但它就在屏幕底部。如果我再次单击该按钮,它会正常显示第五个项目 top.the 项目高度不同。 我应该do.i搜索很多article.but没有answer.thanks错误的效果图see this picture

像这样从你的 recyclerView 列表中获取 linearLayoutManager:

((LinearLayoutManager) mList.getLayoutManager()).scrollToPositionWithOffset(mPositionToScroll, 0);

请告诉我您定义回收视图的方式