Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect that the HorizontalScrollView has reached an end

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.

like image 803
jack Avatar asked Mar 07 '12 08:03

jack


1 Answers

    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); 
    }
like image 66
jack Avatar answered Nov 02 '22 10:11

jack