如何提高的WebView加载时间 [英] How to improve webview load time
问题描述
我有我可以的WebView加载一个URL。如果我通过浏览器中打开的WebView它需要较少的时间,但如果我的WebView加载的URL需要更多的时间。另外,如果我必须用相同的URL在另一个屏幕,然后我不能这样做,因为,如果我用同样的WebView对象在不同的屏幕上随后还需要时间来加载的URL重复使用相同的WebView页面。
如何让我的web视图立即加载一个网址?
在默认情况下,一个web视图不提供类似浏览器的窗口小部件,不 启用JavaScript和网页错误被忽略。
在这里,我贴$ C $的<一个C小部分href="http://$c$c.google.com/p/zirco-browser/source/browse/trunk/src/org/zirco/ui/components/CustomWebView.java"相对=nofollow> zirco浏览器
<$p$p><$c$c>settings.setJavaScriptEnabled(Controller.getInstance().get$p$pferences().getBoolean(Constants.$p$pFERENCES_BROWSER_ENABLE_JAVASCRIPT,真正)); settings.setLoadsImagesAutomatically(Controller.getInstance().get$p$pferences().getBoolean(Constants.$p$pFERENCES_BROWSER_ENABLE_IMAGES,真正)); settings.setUseWideViewPort(Controller.getInstance().get$p$pferences().getBoolean(Constants.$p$pFERENCES_BROWSER_USE_WIDE_VIEWPORT,真正)); settings.setLoadWithOverviewMode(Controller.getInstance().get$p$pferences().getBoolean(Constants.$p$pFERENCES_BROWSER_LOAD_WITH_OVERVIEW,假)); settings.setSaveFormData(Controller.getInstance().get$p$pferences().getBoolean(Constants.$p$pFERENCES_BROWSER_ENABLE_FORM_DATA,真正)); settings.setSavePassword(Controller.getInstance().get$p$pferences().getBoolean(Constants.$p$pFERENCES_BROWSER_ENABLE_PASSWORDS,真正)); settings.setDefaultZoom(ZoomDensity.valueOf(Controller.getInstance().get$p$pferences().getString(Constants.$p$pFERENCES_DEFAULT_ZOOM_LEVEL, ZoomDensity.MEDIUM.toString()))); settings.setUserAgentString(Controller.getInstance().get$p$pferences().getString(Constants.$p$pFERENCES_BROWSER_USER_AGENT, Constants.USER_AGENT_DEFAULT));I have a URL which I can load in webview. If I 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?
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));
这篇关于如何提高的WebView加载时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!