问题
I want to scroll the RecyclerView to a position, and I use LinearLayoutManager.scrollToPositionWithOffset() to scroll, but it does not work. Could any one help me?
My code:
init the RecyclerView:
mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
and in the Button onClick, I do this to scroll the View:
((LinearLayoutManager)mRecyclerView.getLayoutManager()).scrollToPositionWithOffset(position, offset);
回答1:
I think you should use mRecyclerView.smoothScrollToPosition(position) where position is your current position + offset.
来源:https://stackoverflow.com/questions/31265476/recyclerview-linearlayoutmanager-scrolltopositionwithoffset-dose-not-work