在onTouchListener中可以監聽到使用者的點選行為,但是ScrollView在MotionEvent.Action_UP之後還會滑動一段距離,這時候就需要起一個延時的handler,這個handler實時記錄當前ScrollView的滑動距離,以此來判斷滑動狀態interface onScrollListener{ void onScrollStop(); void onScroll(int y);}scrollView.setOnTouchListener(new OnTouchListener() { private int lastY = 0; private int touchEventId = 1001; private OnScrollListener listener; Handler handler = new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); View scroller = (View) msg.obj;
在onTouchListener中可以監聽到使用者的點選行為,但是ScrollView在MotionEvent.Action_UP之後還會滑動一段距離,這時候就需要起一個延時的handler,這個handler實時記錄當前ScrollView的滑動距離,以此來判斷滑動狀態interface onScrollListener{ void onScrollStop(); void onScroll(int y);}scrollView.setOnTouchListener(new OnTouchListener() { private int lastY = 0; private int touchEventId = 1001; private OnScrollListener listener; Handler handler = new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); View scroller = (View) msg.obj;