使用递归调用的方法,每隔5毫秒检查一下是否已经停止,如果已经停止,就拿到事件啦!
不扯蛋,直接上代码。
scrollContent就是我的scrollview。
[代码]java代码:
ScrollView scrollContent ;scrollContent.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), 5); lastY = scroller.getScrollY(); } } }};@Overridepublic boolean onTouch(View v, MotionEvent event) { if(event.getAction() == MotionEvent.ACTION_UP) { handler.sendMessageDelayed(handler.obtainMessage(touchEventId,v), 5); } return false;}//这里写真正的事件private void handleStop(Object view) { ScrollView scroller = (ScrollView) view; System.out.println(scroller.getScrollY()); System.out.println(scroller.getHeight()); //Do Something }});