I have a RecyclerView which I want to be scrolled only programmatically with smoothScrollToPosition command and not from user swipe events. I tried all the solutions from this post without success.
Any suggestions on how to solve this problem?
I have a RecyclerView which I want to be scrolled only programmatically with smoothScrollToPosition command and not from user swipe events. I tried all the solutions from this post without success.
Any suggestions on how to solve this problem?
I didn't yet try it but I think overriding the onTouch will do the trick. You could do:
mRecyclerview.setOnTouchLisntener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
These methods will consume the touch event while doing nothing with it.
EDIT: Noticed you need to keep the click functionality:
mRecyclerview.setOnTouchLisntener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
return true;
case MotionEvent.ACTION_UP:
return false;
case MotionEvent.ACTION_MOVE:
return true;
}
return false;
}
});