How to detect that the HorizontalScrollView has reached an end

…衆ロ難τιáo~ 提交于 2020-01-03 10:58:18

问题


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.


回答1:


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


来源:https://stackoverflow.com/questions/9597943/how-to-detect-that-the-horizontalscrollview-has-reached-an-end

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!