Javascript 使用google文档查看器在webview中加载PDF。不在7.0中滚动
我在使用WebView加载GoogleDocs查看器并从另一个URL显示PDF时,一直有一种非常奇怪的行为 基本上,它在安卓6.0中工作正常,但当我在7.0上试用时,它就不会滚动了。我试着加载其他网页,它们滚动的很好,甚至试着给docs viewer提供不同的PDF,结果都是一样的 这是我的布局文件:Javascript 使用google文档查看器在webview中加载PDF。不在7.0中滚动,javascript,android,pdf,webview,Javascript,Android,Pdf,Webview,我在使用WebView加载GoogleDocs查看器并从另一个URL显示PDF时,一直有一种非常奇怪的行为 基本上,它在安卓6.0中工作正常,但当我在7.0上试用时,它就不会滚动了。我试着加载其他网页,它们滚动的很好,甚至试着给docs viewer提供不同的PDF,结果都是一样的 这是我的布局文件: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.an
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Irrelevant items cut to make this shorter... -->
<WebView
android:id="@+id/WebView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
这是我的代码:
final WebSettings settings = webView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setLoadsImagesAutomatically(true);
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN_MR2) {
settings.setRenderPriority(WebSettings.RenderPriority.HIGH);
}
webView.setWebChromeClient(new WebChromeClient() {
/**
* {@inheritDoc}
*/
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
Log.w(String.format("onConsoleMessage: %s -- From line %s of %s", consoleMessage.message(), consoleMessage.lineNumber(),
consoleMessage.sourceId()));
return true;
}
});
webView.loadUrl("https://docs.google.com/viewer?url=" + webViewUrl);
final WebSettings settings=webView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setLoadsImagesAutomatically(true);
如果(Build.VERSION.SDK_INT Use。我知道其他替代方案,但这不是由我来决定的。我认为,在缺乏解决方案的情况下,使用ACTION_VIEW几乎是我们的B计划。我们最终使用了。它适合我们的需要,效果非常好。使用。我知道其他替代方案,但这不是由我来决定的。使用ACTION_VIEW我认为,这几乎是我们的B计划,因为没有解决方案。我们最终使用了它。它适合我们的需要,而且效果非常好。