How can I stop zoom in webpage of webview in android for HTC mobiles when clicking in input text . Any suggestions will be appreciated .
Asked
Active
Viewed 98 times
0
-
Check this http://stackoverflow.com/questions/5125851/enable-disable-zoom-in-android-webview – Aniruddha Aug 27 '14 at 06:01
-
webView.getSettings().setUseWideViewPort(false); – Naveen Tamrakar Aug 27 '14 at 07:33
3 Answers
0
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;
}
}

Naveen Tamrakar
- 3,349
- 1
- 19
- 28
-
I've already checked out that. But the code is not working in HTC mobiles. As i think HTC has already did certain customizations to web view so that our zoom options don't work over there. – Ram Aug 27 '14 at 07:19
-
0
public class HelpWebView extends WebView {
private GestureDetector gestureDetector;
private AtomicBoolean mPreventAction = new AtomicBoolean(false);
private AtomicLong mPreventActionTime = new AtomicLong(0);
public HelpWebView(Context context) {
super(context);
gestureDetector = new GestureDetector(context, new GestureListener());
}
public HelpWebView(Context context, AttributeSet attrs) {
super(context, attrs);
gestureDetector = new GestureDetector(context, new GestureListener());
}
public HelpWebView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
gestureDetector = new GestureDetector(context, new GestureListener());
}
public HelpWebView(Context context, AttributeSet attrs, int defStyle, boolean privateBrowsing) {
super(context, attrs, defStyle, privateBrowsing);
gestureDetector = new GestureDetector(context, new GestureListener());
}
@Override
public boolean onTouchEvent(MotionEvent event) {
int index = (event.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
int pointId = event.getPointerId(index);
// just use one(first) finger, prevent double tap with two and more fingers
if (pointId == 0){
gestureDetector.onTouchEvent(event);
if (mPreventAction.get()){
if (System.currentTimeMillis() - mPreventActionTime.get() > ViewConfiguration.getDoubleTapTimeout()){
mPreventAction.set(false);
} else {
return true;
}
}
return super.onTouchEvent(event);
} else {
return true;
}
}
private class GestureListener extends GestureDetector.SimpleOnGestureListener {
@Override
public boolean onDoubleTap(MotionEvent e) {
mPreventAction.set(true);
mPreventActionTime.set(System.currentTimeMillis());
return true;
}
@Override
public boolean onDoubleTapEvent(MotionEvent e) {
mPreventAction.set(true);
mPreventActionTime.set(System.currentTimeMillis());
return true;
}
}
}

Naveen Tamrakar
- 3,349
- 1
- 19
- 28
0
Finally, what i have observed with HTC is It has customized android OS and our webview settings never work there. Though i have customized webview there is no use. And i worked out on my issue in other way.
It only has FAR,CLOSE,MEDIUM settings in webview zoom.that has already set.But we can change them at setting of mobile.Apart from that we can't change anything.

Ram
- 114
- 12