【android】判断HorizontalScrollView/ScrollView滑到最左/上和最右/下

时间:2015-03-23 15:27:42   收藏:0   阅读:1219

HorizontalScrollView:

    @Override
    protected void onScrollChanged(int l, int t, int oldl, int oldt) {
    	// TODO Auto-generated method stub
    	super.onScrollChanged(l, t, oldl, oldt);
    	int  maxScrollX = getChildAt(0).getMeasuredWidth()-getMeasuredWidth(); 
        //滑到最左
        if (getScrollX() == 0 ) { 
        	
        }else if (getScrollX() == maxScrollX) {  //滑到最右
        	
		}else {  //滑到中间

		}
    }


ScrollView:

只需将上面代码中的ScrollX改为ScrollY,MeasuredWidth改为MeasuredHeight即可




参考http://stackoverflow.com/questions/9597943/how-to-detect-that-the-horizontalscrollview-has-reached-an-end

原文:http://blog.csdn.net/u011494050/article/details/44562113

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!