I haven't tested this on any other devices but on a 2.1 device, in a WebView with the zoom controls turned on, a toast message sometimes comes up that says something like "Tip: double tap to zoom in and out". I don't know where it is coming from as nothing in my code asked for it to appear. Is there any way to disable this?
I don't know how to reproduce it but it seems to happen more often when the app is freshly installed.
As indicated in wajiw's answer, the toast is based on the double tap toast count in WebSettings. There is a workaround based on preempting that value. WebSettings gets its value for double tap toast count from SharedPreferences. Overriding the preferences value will disable the toast.
The preferences are based on private values in WebSettings so it's not ideal. If the implementation changes, this could very well stop working. So, use at your own risk.
Here are the values WebSettings uses for the SharedPreferences. You'll need to duplicate them in your class.
private static final String PREF_FILE = "WebViewSettings";
private static final String DOUBLE_TAP_TOAST_COUNT = "double_tap_toast_count";
Then, you'll need to change the values before you use the WebView
SharedPreferences prefs = context.getSharedPreferences(PREF_FILE, Context.MODE_PRIVATE);
if (prefs.getInt(DOUBLE_TAP_TOAST_COUNT, 1) > 0) {
prefs.edit().putInt(DOUBLE_TAP_TOAST_COUNT, 0).commit();
}
Check out WebSettings source code for more info.
From looking at the WebView.java source it's coming from the startDrag function:
private void startDrag() {
WebViewCore.reducePriority();
// to get better performance, pause updating the picture
WebViewCore.pauseUpdatePicture(mWebViewCore);
if (!mDragFromTextInput) {
nativeHideCursor();
}
WebSettings settings = getSettings();
if (settings.supportZoom()
&& settings.getBuiltInZoomControls()
&& !getZoomButtonsController().isVisible()
&& mMinZoomScale < mMaxZoomScale
&& (mHorizontalScrollBarMode != SCROLLBAR_ALWAYSOFF
|| mVerticalScrollBarMode != SCROLLBAR_ALWAYSOFF)) {
mZoomButtonsController.setVisible(true);
int count = settings.getDoubleTapToastCount();
if (mInZoomOverview && count > 0) {
settings.setDoubleTapToastCount(--count);
Toast.makeText(mContext,
com.android.internal.R.string.double_tap_toast,
Toast.LENGTH_LONG).show();
}
}
}
the settings are accessible through getSettings(). From there I would try to call setDoubleTapToastCount and use something like 0 or -1 for the value. If that doesn't work you may be out of luck.
See full source of WebView.java here
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