如何刷新在 RecyclerView中显示的数据(在其适配器上调用 notifyDataSetChanged)并确保滚动位置被重置到确切的位置?
在良好的 ol’ListView的情况下,它只需要检索 getChildAt(0),检查它的 getTop(),然后用相同的确切数据调用 setSelectionFromTop。
It doesn't seem to be possible in case of RecyclerView.
我想我应该使用它的 LayoutManager的确提供了 scrollToPositionWithOffset(int position, int offset),但是什么是正确的方法来检索位置和偏移?
layoutManager.findFirstVisibleItemPosition()和 layoutManager.getChildAt(0).getTop()?
还是有更优雅的方式来完成工作?