Abh*_*k V 15 pdf android google-docs android-webview google-drive-api
我通过将pdf url附加到google doc api来加载WebView中的pdf文档
http://docs.google.com/gview?embedded=true&url=myurl
Pdf加载得很好,但网页显示两个选项 - Zoom-in和Pop-Out.有没有办法通过发送一些参数来禁用/隐藏弹出选项?任何帮助将不胜感激.谢谢!

小智 10
您可以添加此回调,结果"弹出"按钮将被删除.
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
mWebView.loadUrl("javascript:(function() { " +
"document.querySelector('[role=\"toolbar\"]').remove();})()");
}
Run Code Online (Sandbox Code Playgroud)
注意:如果您现在想要显示此按钮,请在应用上一个javascript代码后显示您的Web视图.
//initialze WebView
webview = (WebView) findViewById(R.id.fullscree_webview);
//set the javascript enable to your webview
webview.getSettings().setJavaScriptEnabled(true);
//set the WebViewClient
webview.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'; })()");
}
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5729 次 |
| 最近记录: |