N-JOY
N-JOY

Reputation: 7635

Android webview zooming buttons

how can I prevent zoom controls in webview from disappearing after zooming in or out.

and these zoom controls always show up after sliding the webview i.e. zoom controls do not show up autmatically as soon as webview loads up.

I have tried this code.

webview = (WebView)findViewById(R.id.webview);                                                                                                                                                                                                             
//getWindow().requestFeature(Window.FEATURE_PROGRESS);
WebSettings webSettings = webview.getSettings(); 
webSettings.setJavaScriptEnabled(true); 
webSettings.setLoadsImagesAutomatically(true);
webSettings.setSupportZoom(true) ;
webSettings.setBuiltInZoomControls(true);
// findViewById(R.id.LinearLayout01).;
 webview.invokeZoomPicker();

Upvotes: 2

Views: 7141

Answers (1)

Justin Pearce
Justin Pearce

Reputation: 5097

Your best bet is to implement a ZoomButtonsController.


class myClass implements ZoomButtonsController.OnZoomListener{

     public ZoomButtonsController zoomy;
     private WebView myWebView;

     public myClass(){
      zoomy = new ZoomButtonsController(this);
      zoomy.setOnZoomListener(this);
      zoomy.setZoomSpeed(500);
      zoomy.setAutoDismiss(false);
     }

    @Override
    public void onZoom(boolean zoomIn) {
        if(zoomIn){
            myWebView.zoomIn();
        }else{
            myWEbView.zoomOut();
        }
    }

    public void toggleZoom(){
       if(!zoomy.isVisible()){
          zoomy.setVisible(true);
       }else{
          zoomy.setVisible(false);
       }
    }

}

Hope this gets you going in the right direction.

Upvotes: 4

Related Questions