Android WebView : Remove pop-out option in google drive/doc viewer Android WebView : Remove pop-out option in google drive/doc viewer android android

Android WebView : Remove pop-out option in google drive/doc viewer


You can add this callback and in a result "pop-out" button will be removed.

@Override    public void onPageFinished(WebView view, String url) {        super.onPageFinished(view, url);        mWebView.loadUrl("javascript:(function() { " +                "document.querySelector('[role=\"toolbar\"]').remove();})()");    }

Note: If you want to now show this button at all, make your web view visible after applying last javascript code.


//initialze WebViewwebview = (WebView) findViewById(R.id.fullscree_webview);//set the javascript enable to your webviewwebview.getSettings().setJavaScriptEnabled(true);//set the WebViewClientwebview.setWebViewClient(new WebViewClient() {//once the page is loaded get the html element by class or id and through javascript hide it.        @Override        public void onPageFinished(WebView view, String url) {            super.onPageFinished(view, url);            webview.loadUrl("javascript:(function() { " +                    "document.getElementsByClassName('ndfHFb-c4YZDc-GSQQnc-LgbsSe ndfHFb-c4YZDc-to915-LgbsSe VIpgJd-TzA9Ye-eEGnhe ndfHFb-c4YZDc-LgbsSe')[0].style.display='none'; })()");        }    })


mWebview = (WebView) findViewById(R.id.your_web_view_id);//do the javascript enable to your webviewmWebview .getSettings().setJavaScriptEnabled(true);//set the WebViewClientmWebview .setWebViewClient(new WebViewClient() {//add this line to Hide pop-out tool bar of pdfview in pagLoadFinish        @Override        public void onPageFinished(WebView view, String url) {            super.onPageFinished(view, url);             mWebview .loadUrl("javascript:(function() {document.querySelector('[class=\"ndfHFb-c4YZDc-Wrql6b\"]').remove();})()")        }    })

This will remove the pop-out toolbar which is the redirection in chrome browser

Happy Coding