There are some methods in WebSettings related to zoom:
I noticed they work differently on some devices. For example, on my Galaxy S pinch to zoom is enabled by default, but on LG P500 it is disabled (And now I don't know how to enable ONLY pinch to zoom, but hide zooming buttons).
On P500 when I call setBuiltInZoomControls(true)
I get both these variants working (multitouch and buttons).
How to enable multitouch zoom and disable zooming buttons on devices such an LG P500? (Also, I know the same problems are on HTC devices)
UPDATE: Here is almost full code for the solution
if (ev.getAction() == MotionEvent.ACTION_DOWN || ev.getAction() == MotionEvent.ACTION_POINTER_DOWN || ev.getAction() == MotionEvent.ACTION_POINTER_1_DOWN || ev.getAction() == MotionEvent.ACTION_POINTER_2_DOWN || ev.getAction() == MotionEvent.ACTION_POINTER_3_DOWN) { if (multiTouchZoom && !buttonsZoom) { if (getPointerCount(ev) > 1) { getSettings().setBuiltInZoomControls(true); getSettings().setSupportZoom(true); } else { getSettings().setBuiltInZoomControls(false); getSettings().setSupportZoom(false); } } } if (!multiTouchZoom && buttonsZoom) { if (getPointerCount(ev) > 1) { return true; } }
This code is in my onTouchEvent
overridden method of the WebView.
webSettings. setBuiltInZoomControls(true); webSettings. setSupportZoom(true);
getSettings(). setBuiltInZoomControls(true); per this answer to default my view to zoomed out and to be able to pinch-to-zoom.
Show activity on this post. How to disable zoom on react-native web-view ,is there a property like hasZoom={false} (just an example) that can be included in the below web-view tag that can disable zooming.
In Android, Zoom Control is a class that has some set of methods that are used to control the zoom functionality. It has two buttons that are used to control the zoom functionality (ie Zoom In and Zoom Out). Zoom Control Class has been deprecated in API Version 29.
On API >= 11, you can use:
wv.getSettings().setBuiltInZoomControls(true); wv.getSettings().setDisplayZoomControls(false);
As per the SDK:
public void setDisplayZoomControls (boolean enabled)
Since: API Level 11
Sets whether the on screen zoom buttons are used. A combination of built in zoom controls enabled and on screen zoom controls disabled allows for pinch to zoom to work without the on screen controls
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With