• 12

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

Detect scroll end in android.widget.Scroller

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?

public boolean onTouchEvent(MotionEvent event) {
    if(event.getAction() == MotionEvent.ACTION_UP) {
      if(mIsScrolling) {
        mIsScrolling = false;
    return mGestureDetector.onTouchEvent(event);

you can do this by simple math

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


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


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

for reference the doc here Scroller

  • 1
Reply Report