I read many tickets on the topic of Zooming in WebViews and didnt came to an answer for my case.
Here´s my setup:
I´m using a custom webview with generally
There are two methods to achieve your goal:
Method 1
Implement the GestureDetector.OnDoubleTapListener like this:
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
return false; //Nothing
}
@Override
public boolean onDoubleTap(MotionEvent e) {
//Indicates that this implementation has handled the double tap.
return true;
}
@Override
public boolean onDoubleTapEvent(MotionEvent e) {
//Indicates that this implementation has handled the double tap.
return true;
}
and attach it to your GestureDetector like this:
gestureDetector.setOnDoubleTapListener(this);
Method 2
You can also use the WebSettings.setUseWideViewPort(false); and calculate the size of your view manually.
These methods should help you to achieve non-zoomable webviews that display everything.
public int getWindowWidth(Activity activity) {
Display display = ((WindowManager) activity.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
return width;
}
public int getInitialScale(Activity activity, int websiteWidth) {
return (getWindowWidth(activity) / websiteWidth) * 100;
}