开发者

Android webview zooming buttons

开发者 https://www.devze.com 2023-01-17 11:06 出处:网络
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 a

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.setL开发者_JAVA百科oadsImagesAutomatically(true);
webSettings.setSupportZoom(true) ;
webSettings.setBuiltInZoomControls(true);
// findViewById(R.id.LinearLayout01).;
 webview.invokeZoomPicker();


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消