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

Abhishek V picture Abhishek V · Dec 31, 2014 · Viewed 7.4k times · Source

I am loading the pdf documents in WebView through appending the pdf url to google doc api

http://docs.google.com/gview?embedded=true&url=myurl

Pdf is loading just fine but the webpage displays two options - Zoom-in and Pop-Out. Is there any way to disable/hide pop-out option by sending some param? Any help would be appreciated.Thanks in advance!

enter image description here

Answer

Karim Karimov picture Karim Karimov · Mar 26, 2017

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.