How to safely turn WebView zooming on and off as needed

前端 未结 9 1260
后悔当初
后悔当初 2020-12-15 01:06

As mentioned in this unanswered question: WebView throws Receiver not registered: android.widget.ZoomButtonsController

By turning the WebView zoom controls on and of

9条回答
  •  难免孤独
    2020-12-15 01:42

    This solution works fine, you simply need to remove the webview from the layout before destroying it:

    @Override
        public void onDestroy() {
            if (webView!=null && webView.getParent()!=null){
                ((ViewGroup)webView.getParent()).removeView(webView);
                webView.destroy();
                webView=null;
            }
            super.onDestroy();
        }
    

    No handlers, no delays, i think it's the best solution

提交回复
热议问题