2

I would like to detect when a user stops scrolling using android.widget.Scroller based on onTouchEvent checking MotionEvent.ACTION_UP. When the user scrolls once it works fine but when the user scrolls quickly to reach particularly position it shows that the user scrolled many times though I want to detect it as one scroll. How can I achieve that?

@Override
public boolean onTouchEvent(MotionEvent event) {
    if(event.getAction() == MotionEvent.ACTION_UP) {
      if(mIsScrolling) {
        mIsScrolling = false;
        //
      }
    }
    mScaleDetector.onTouchEvent(event);
    return mGestureDetector.onTouchEvent(event);
}
Atalyk
  • 495
  • 1
  • 5
  • 11

1 Answers1

1

you can do this by simple math

getCurrX(), getCurrY() methods returns current offset position x and y of scroller respectively

similarly

getFinalX(), getFinalY() methods returns current offset positions x and y of scroller respectively

so

if(getCurrY() == getFinalY()) // true means you reached end of the scroller

for reference the doc here Scroller

Dharman
  • 30,962
  • 25
  • 85
  • 135
Jayanth
  • 5,954
  • 3
  • 21
  • 38