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.
Asked
Active
Viewed 5,200 times
6
-
1This 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 Answers
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