RecyclerView setSelected 和滚动?
RecyclerView setSelected and scrolling?
在ListView
中,getListView().setSelection(n);
用于直接滚动,getListView().smoothScrollToPosition(n);
用于平滑滚动。
这在 RecyclerView
中可能吗?
你必须使用 scrollToPositionWithOffset。
//Scroll item 2 to 20 pixels from the top
linearLayoutManager.scrollToPositionWithOffset(2, 20);
这个问题是answered before。
在ListView
中,getListView().setSelection(n);
用于直接滚动,getListView().smoothScrollToPosition(n);
用于平滑滚动。
这在 RecyclerView
中可能吗?
你必须使用 scrollToPositionWithOffset。
//Scroll item 2 to 20 pixels from the top
linearLayoutManager.scrollToPositionWithOffset(2, 20);
这个问题是answered before。