I have been trying to open a pdf file by URL in a full screen WebView. Loading the file is no issue, but performance is a BIG one. Scrolling is almost non-responsive, with changes appearing up to 5 seconds after the scroll. Same idea for zooming in/out. This makes the activity almost unusable.
Here's how I'm opening the pdf:
WebView webView = (WebView)findViewById(R.id.webview);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("http://docs.google.com/gview?embedded=true&url=" + url);
I have tried to set hardwareAccelerated
to true and to false in the AndroidManifest
, which had no change.
I have tried the solution found here about setting render priority, but that has also had no change on performance.
I have tried to set the Layer Type (mWebView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
), but this has also had no effect on the performance.
The pdf file itself is very small at about 6 pages. It is 177Kb in size. The phone I am testing on is a Samsung Galaxy S5, so hardware performance is no issue. The network connection is very good. This leads me to believe there is either something wrong with my code, or with the WebView or Google Viewer.
How can I improve performance on this webview?
edit: I have tried a different pdf file, same result.