private void init() { mScrollView = (ScrollView) findViewById(R.id.scrollview); mScrollView.setOnTouchListener(new TouchListenerImpl()); } class TouchListenerImpl implements OnTouchListener { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: break; case MotionEvent.ACTION_MOVE: // ScollView顶端已经滑出去的高度 int scrollY = v.getScrollY(); // ScollView的可见高度 int height = v.getHeight(); // ScollView所占的高度 int measuredHeight = mScrollView.getChildAt(0) .getMeasuredHeight(); if (scrollY == 0) { Log.d(TAG, "滑动到顶端"); Log.d(TAG, scrollY+""); Log.d(TAG, measuredHeight+""); } if ((scrollY + height) == measuredHeight) { Log.d(TAG, scrollY+""); Log.d(TAG, height+""); Log.d(TAG, measuredHeight+""); } break; } return false; } }
//Android中监听ScrollView滑动停止和滑动到底部 :