6

i want when reach to end ,the right button will change color ,when reach to the begin,the left button will change color ,so ,i want to ask how to detect that the HorizontalScrollView has reached an end.

Joe Doyle
  • 6,363
  • 3
  • 42
  • 45
jack
  • 181
  • 1
  • 5
  • 1
    This Link will help you: [http://stackoverflow.com/questions/2089552/android-how-to-detect-when-a-scroll-has-ended][1] [1]: http://stackoverflow.com/questions/2089552/android-how-to-detect-when-a-scroll-has-ended – Sadeshkumar Periyasamy Mar 07 '12 at 08:28
  • [this post might help you](http://stackoverflow.com/a/3952629/593709) – Adil Soomro Mar 07 '12 at 08:29
  • maxScrollX = horizontalScrollView.getChildAt(0) .getMeasuredWidth()-horizontalScrollView.getMeasuredWidth(); if (horizontalScrollView.getScrollX()==0) { lImageView.setImageResource(R.drawable.left_green); }else { lImageView.setImageResource(R.drawable.left); } if (horizontalScrollView.getScrollX()==maxScrollX) { rImageView.setImageResource(R.drawable.right_green); }else { rImageView.setImageResource(R.drawable.right); } – jack Mar 08 '12 at 03:36

1 Answers1

12
    maxScrollX = horizontalScrollView.getChildAt(0).getMeasuredWidth()-horizontalScrollView.getMeasuredWidth(); 
    if (horizontalScrollView.getScrollX() == 0) { 
        lImageView.setImageResource(R.drawable.left_green); 
    } else { 
        lImageView.setImageResource(R.drawable.left); 
    }

    if (horizontalScrollView.getScrollX() == maxScrollX) { 
        rImageView.setImageResource(R.drawable.right_green); 
    } else { 
        rImageView.setImageResource(R.drawable.right); 
    }
Igor Konoplyanko
  • 9,176
  • 6
  • 57
  • 100
jack
  • 181
  • 1
  • 5