You should be able to use the distanceY
parameter to determine whether the view was scrolled up or down. distanceY
represents the distance along the Y axis that has been scrolled since the last call to onScroll()
. If the value of distanceY
is greater than zero, the view has been scrolled from a lower position on the Y axis to a higher position on the Y axis.
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
if (distanceY > 0) {
// Scrolled upward
if (e2.getAction() = MotionEvent.ACTION_UP) {
// The pointer has gone up, ending the gesture
}
}
return false;
}
Note: I have not tested if the MotionEvent.ACTION_UP
will solve your need to check when scrolling has ended, but it seems practical in theory. Also note that technically the gesture could also end if the MotionEvent
's action is set to MotionEvent.ACTION_CANCEL
.