6
我想要達到結束時,右按鈕將更改顏色,當到達開始時,左按鈕將更改顏色,所以,我想問如何檢測HorizontalScrollView已結束。如何檢測到HorizontalScrollView已到達結尾
我想要達到結束時,右按鈕將更改顏色,當到達開始時,左按鈕將更改顏色,所以,我想問如何檢測HorizontalScrollView已結束。如何檢測到HorizontalScrollView已到達結尾
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);
}
在哪裏觸發此事件 - 任何偵聽器? – NarendraJi 2015-10-24 11:52:12
這個鏈接將幫助您: [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 – 2012-03-07 08:28:21
[此帖可能會幫助你(HTTP: //stackoverflow.com/a/3952629/593709) – 2012-03-07 08:29:07
maxScrollX = horizontalScrollView.getChildAt(0) \t \t .getMeasured寬度() - horizontalScrollView.getMeasuredWidth(); 如果(horizontalScrollView.getScrollX()== 0){ \t \t \t \t \t lImageView.setImageResource(R.drawable.left_green); \t \t \t \t}否則{ \t \t \t \t \t lImageView.setImageResource(R.drawable.left); \t \t \t \t} \t \t \t \t如果(horizontalScrollView.getScrollX()== maxScrollX){ \t \t \t \t \t rImageView.setImageResource(R.drawable.right_green); \t \t \t \t}否則{ \t \t \t \t \t rImageView.setImageResource(R.drawable.right); \t \t \t \t} – jack 2012-03-08 03:36:55