How to improve webview load time
I have a URL which I can load in webview. If 开发者_StackOverflowI open the webview through browser it takes less time, but if I load the URL in webview it takes more time. Also if I have to reuse the same webview page with the same URL in another screen then I am unable to do that because if I use the same webview object in different screens then also it takes time to load the URL.
How do I make my webview to load a URL instantly?
You could use the YSlow or Google PageLoad plugins for your browser, to get specific tips on how to improve page load and speed up your page.
You could try a different cache mode: http://developer.android.com/reference/android/webkit/WebSettings.html#setCacheMode%28int%29
or, if the page doesn't change, just use loadDataWithBaseURL: http://developer.android.com/reference/android/webkit/WebView.html#loadDataWithBaseURL%28java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String%29
By default, a WebView provides no browser-like widgets, does not enable JavaScript and web page errors are ignored.
here i paste small part of code of zirco-browser
settings.setJavaScriptEnabled(Controller.getInstance().getPreferences().getBoolean(Constants.PREFERENCES_BROWSER_ENABLE_JAVASCRIPT, true));
settings.setLoadsImagesAutomatically(Controller.getInstance().getPreferences().getBoolean(Constants.PREFERENCES_BROWSER_ENABLE_IMAGES, true));
settings.setUseWideViewPort(Controller.getInstance().getPreferences().getBoolean(Constants.PREFERENCES_BROWSER_USE_WIDE_VIEWPORT, true));
settings.setLoadWithOverviewMode(Controller.getInstance().getPreferences().getBoolean(Constants.PREFERENCES_BROWSER_LOAD_WITH_OVERVIEW, false));
settings.setSaveFormData(Controller.getInstance().getPreferences().getBoolean(Constants.PREFERENCES_BROWSER_ENABLE_FORM_DATA, true));
settings.setSavePassword(Controller.getInstance().getPreferences().getBoolean(Constants.PREFERENCES_BROWSER_ENABLE_PASSWORDS, true));
settings.setDefaultZoom(ZoomDensity.valueOf(Controller.getInstance().getPreferences().getString(Constants.PREFERENCES_DEFAULT_ZOOM_LEVEL, ZoomDensity.MEDIUM.toString())));
settings.setUserAgentString(Controller.getInstance().getPreferences().getString(Constants.PREFERENCES_BROWSER_USER_AGENT, Constants.USER_AGENT_DEFAULT));
set render priority high for your web view can solve problem up to some extent its some thing like this
webview.getSettings().setRenderPriority(RenderPriority.HIGH);
精彩评论