开发者

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.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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜