Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to hide and show the zoom controls on a WebView?

I have a two Views. One is a WebView and the other is an ImageView. I set the auto zoom controls for the WebView like so:

webview.getSettings().setBuiltInZoomControls(true);

I am just changing the visibility of both Views using GONE and Visible. While changing my View from WebView to ImageView, the zoom controls do not lose their visibility for some period of time.

Is there any possible way to hide and show the Autozoomcontrols?

Edit:

I tried these methods, but it's still not working.

webview.getZoomControls().setVisibility(View.GONE);
webview.getZoomControls().invalidate();
like image 329
Praveen Avatar asked Jul 02 '10 09:07

Praveen


People also ask

How to remove zoom buttons on Android WebView?

getSettings(). setBuiltInZoomControls(false); use the above line of code to remove the zoom buttons.

Which method is used to hide zoom controls from the screen?

hide(): This method is used to hide the ZoomControls from the screen.


1 Answers

public void setZoomControlGone(View view){
    Class<?> classType;
    Field field;
    try {
        classType = WebView.class;
        field = classType.getDeclaredField("mZoomButtonsController");
        field.setAccessible(true);
        ZoomButtonsController mZoomButtonsController = new ZoomButtonsController(view);
        mZoomButtonsController.getZoomControls().setVisibility(View.GONE);
        try {
            field.set(view, mZoomButtonsController);
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    } catch (SecurityException e) {
        e.printStackTrace();
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    }
}
like image 92
Tim Wong Avatar answered Oct 25 '22 17:10

Tim Wong