How to disable doubletap zoom in android webview?

后端 未结 4 1099
不知归路
不知归路 2020-12-18 13:51

How to disable the doubletap zoom in android webview. I have tried many things but it haven\'t worked. Please suggest me the right solution to achieve this .

4条回答
  •  轮回少年
    2020-12-18 13:56

    Override the onTouchEvent in your WebView.
    It works in all cases.

    @Override
    public boolean onTouchEvent( MotionEvent event ) {
    
        if (event.getAction() == MotionEvent.ACTION_UP) {
    
            event.setAction(MotionEvent.ACTION_CANCEL);
            super.onTouchEvent(event);
            event.setAction(MotionEvent.ACTION_DOWN);
            super.onTouchEvent(event);
            event.setAction(MotionEvent.ACTION_UP);
        }
    
    return super.onTouchEvent(event);
    }
    

提交回复
热议问题