思路是当滑动开始时不停的监听scrollview的高度,当高度不变时说明滑动已经停止
scrollView.setOnTouchListener(new OnTouchListener() { private int lastY = 0; private int touchEventId = -9983761; Handler handler = new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); View scroller = (View)msg.obj; if(msg.what==touchEventId) { if(lastY ==scroller.getScrollY()) { handleStop(scroller); }else { handler.sendMessageDelayed(handler.obtainMessage(touchEventId,scroller), 1); lastY = scroller.getScrollY(); } } } }; @Override public boolean onTouch(View v, MotionEvent event) { isScoll = false; int eventAction = event.getAction(); int y=(int) event.getRawY(); switch (eventAction) { case MotionEvent.ACTION_UP: if(Math.abs(touchY-y)<20){ }else{ handler.sendMessageDelayed(handler.obtainMessage(touchEventId,v), 5); } break; default: break; } return false; } //这里写真正的事件 private void handleStop(Object view) {// } });
?