I want to programmatically scroll a RecyclerView
, is it possible to do something like this?
I have the following code in a custom RecyclerView
in order to dispatch a scrolling event, but I am stuck in figuring out a mock MotionEvent
:
public boolean dispatchHandlerScroll(MotionEvent e) {
switch (e.getAction()) {
case MotionEvent.ACTION_DOWN: {
y = (int) e.getY();
startNestedScroll(2);
break;
}
case MotionEvent.ACTION_MOVE: {
int dY = y - ((int) e.getY());
dispatchNestedPreScroll(0, dY, null, null);
dispatchNestedScroll(0, 0, 0, dY, null);
break;
}
case MotionEvent.ACTION_UP: {
stopNestedScroll();
break;
}
}
return true;
}
Anyone have an idea?