如何在android webview中禁用双击缩放? [英] How to disable doubletap zoom in android webview?
问题描述
如何在 android webview
中禁用双击缩放.我尝试了很多东西,但没有奏效.请建议我实现这一目标的正确解决方案.
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 .
实际上我正在从自定义 html 加载图像.我必须为此禁用完全缩放.
Actually I am loading an image from custom html . I have to disable complete zooming for that.
我已经尝试了以下事情,
I have tried the below things,
webview.getSettings().setSupportZoom(false);
甚至我将元标记保留在 html 中,并将其设为 userscalable= no
.即使它对我不起作用.
and even I kept meta tag in html and I make it as userscalable= no
. Even it doesn't worked for me.
我尝试使用 GestureDetector.SimpleOnGestureListener
请让我知道我必须在 onDoubleTap
中缩放任何东西.
Please let me know that i have to scale anything in onDoubleTap
.
推荐答案
Override
onTouchEvent
在您的 WebView
中.
它适用于所有情况.
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);
}
这篇关于如何在android webview中禁用双击缩放?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!