Disable or prevent multitouch in Activity

前端 未结 9 1743
闹比i
闹比i 2020-11-30 03:11

I have several Views on an Activity which a user wants to touch quickly in succession and I capture these touches using a TouchListener and handling Motio

9条回答
  •  无人及你
    2020-11-30 03:51

    Override dispatchTouchEvent and intercept all touches there, for all multi touches the pointercount is more than one.

     if(ev.getPointerCount() > 1)
      {
         Log.d("Multitouch detected!");
         ev.setAction(MotionEvent.ACTION_CANCEL);
      }
    

    This cancels the touches and clears the pressed state of the buttons without taking any further action.

提交回复
热议问题