如何检测该Horizo​​ntalScrollView已达到结束 [英] How to detect that the HorizontalScrollView has reached an end

查看:127
本文介绍了如何检测该Horizo​​ntalScrollView已达到结束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想,当到达终点,右边的按钮会改变颜色,在到达的开始,左键会变色,所以,我想问问如何检测到Horizo​​ntalScrollView已经到头了。


解决方案

  maxScrollX = horizo​​ntalScrollView.getChildAt(0).getMeasuredWidth() -  horizo​​ntalScrollView.getMeasuredWidth();
    如果(horizo​​ntalScrollView.getScrollX()== 0){
        lImageView.setImageResource(R.drawable.left_green);
    }其他{
        lImageView.setImageResource(R.drawable.left);
    }    如果(horizo​​ntalScrollView.getScrollX()== maxScrollX){
        rImageView.setImageResource(R.drawable.right_green);
    }其他{
        rImageView.setImageResource(R.drawable.right);
    }

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.

解决方案

    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); 
    }

这篇关于如何检测该Horizo​​ntalScrollView已达到结束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆