I have a webview that you can navigate to an embeded link in it. That link is to an image, and I enable zooming when navigating to that image, and disable it when the user goes back. This works fine, except for the zoom controls. For some reason they linger for a little bit when I come back, and this allows the user to mess with the zoom level of a webview that is not intended to be zoomed. Once they fade away they dont come back, i just need some way to immediately disable them, rather than wait for them to fade. Any answers?
I disable zooming like this:
contentView.getSettings().setJavaScriptEnabled(false);
contentView.getSettings().setSupportZoom(false);
contentView.getSettings().setBuiltInZoomControls(false);
Edit:
This is also causing a crash when i try to go back to the previous activity when the controls are still showing. Here is a crash dump from it if it helps fix either problem
FATAL EXCEPTION: main
java.lang.IllegalArgumentException: Receiver not registered: android.widget.ZoomButtonsController$1@47979810
at android.app.ActivityThread$PackageInfo.forgetReceiverDispatcher(ActivityThread.java:859)
at android.app.ContextImpl.unregisterReceiver(ContextImpl.java:869)
at android.content.ContextWrapper.unregisterReceiver(ContextWrapper.java:331)
at android.widget.ZoomButtonsController.setVisible(ZoomButtonsController.java:404)
at android.widget.ZoomButtonsController$2.handleMessage(ZoomButtonsController.java:178)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:143)
at android.app.ActivityThread.main(ActivityThread.java:5073)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
at dalvik.system.NativeStart.main(Native Method)
Edit2:
Heres some of the code, not sure how much this helps
In the activity's onCreate function
contentView = (WebView) findViewById(R.id.message_content);
contentView.setWebViewClient(new WebViewClient()
{
@Override
public void onPageFinished(WebView view, String url )
{
if ( !url.startsWith("http") )
{
view.clearHistory();
}
else
{
contentView.getSettings().setJavaScriptEnabled(true);
contentView.getSettings().setSupportZoom(true);
contentView.getSettings().setBuiltInZoomControls(true);
topButton.setText("Go back");
topButton.setOnClickListener(backClick);
}
}
@Override
public boolean shouldOverrideUrlLoading( WebView view, String url )
{
view.loadUrl(url);
return true;
}
});
And this is how I go back from the zoom-able page
@Override
public boolean onKeyDown( int keyCode, KeyEvent event )
{
if ( keyCode == KeyEvent.KEYCODE_BACK )
{
if ( contentView.canGoBack() )
{
contentView.getSettings().setJavaScriptEnabled(false);
contentView.getSettings().setSupportZoom(false);
contentView.getSettings().setBuiltInZoomControls(false);
topButton.setText("Add a comment");
topButton.setOnClickListener(postClick);
contentView.goBack();
return true;
}
}
return super.onKeyDown(keyCode, event);
}