Disable the touch events for all the views

前端 未结 13 1378
暗喜
暗喜 2020-11-28 06:53

What\'s the best way to disable the touch events for all the views?

13条回答
  •  感情败类
    2020-11-28 07:02

    This piece of code will basically propagate this event to the parent view, allowing the touch event, if and only if the inProgress variable is set to false.

    private boolean inProgress = false;
    
    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        if (!inProgress)
            return super.dispatchTouchEvent(ev);
        return true;
     }
    

提交回复
热议问题