I\'m using RecyclerView, with ScrollListener:
mRecyclerView.setOnScrollListener(new RecyclerView.OnScrollListener()
{
@Override
public void onScr
Please try with
LinearLayoutManager.scrollToPositionWithOffset(int, int).
LayoutManager.scrollToPosition()
may not work well, but LinearLayoutManager.scrollToPositionWithOffset()
will work. And similarlly GridLayoutManager as well.
Or we have to write our custom way of implementation because RecyclerView doesn't know how LayoutManager scrolls the view.
class CustomLayoutManager extends LinearLayoutManager{
public void smoothScrollToPosition(RecyclerView recyclerView,
RecyclerView.State state, final int position) {
LinearSmoothScroller smoothScroller =
new LinearSmoothScroller(mContext) {
//Override the methods and write your implementation as per your requirement
//one which controls the direction and another one calculate the speed per Pixel
}
}
Sometimes this does the trick
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
yourList.scrollToPosition(position);
}
}, 200);