What causes a MotionEvent.ACTION_CANCEL in Android?

后端 未结 4 1757
情书的邮戳
情书的邮戳 2021-02-03 19:25

I am working through debugging some touch handling stuff on Android, and am trying to figure out why the MotionEvent sent to my View\'s onTouchListener contains a <

4条回答
  •  悲&欢浪女
    2021-02-03 20:18

    All you need is to call

    requestDisallowInterceptTouchEvent(true);
    

    on the parent view, like this -

            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {
                view.getParent().requestDisallowInterceptTouchEvent(true);
                switch(motionEvent.getActio){
                }
    
                return false; 
    
             }
    

    Source: onInterceptTouchEvent, onTouchEvent only see ACTION_DOWN

提交回复
热议问题