我希望当到达结束时,右键会改变颜色,当到达开头时,左键会改变颜色,所以,我想问一下如何检测HorizontalScrollView已经到了结尾。
答案 0 :(得分: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);
}