A Quick note on WebView
A View that displays web pages. This class is the basis upon which you can roll your own web browser or simply display some online content within your Activity. It uses the WebKit rendering engine to display web pages and includes methods to navigate forward and backward through a history, zoom in and out, perform text searches and more.
Note that, in order for your Activity to access the Internet and load web pages in a WebView, you must add the INTERNET permissions to your Android Manifest file:
<uses-permission android:name="android.permission.INTERNET" />
Improve WebView Performance
Follow these simple coding tricks to improve Android WebView Performance.
WebView mWebView = new WebView(this); WebSettings settings = mWebView.getSettings(); settings.setJavaScriptEnabled(true); settings.setLoadWithOverviewMode(true); settings.setUseWideViewPort(true); settings.setSupportZoom(true); settings.setBuiltInZoomControls(false); settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); settings.setCacheMode(WebSettings.LOAD_NO_CACHE); settings.setDomStorageEnabled(true); mWebView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY); mWebView.setScrollbarFadingEnabled(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { mWebView.setLayerType(View.LAYER_TYPE_HARDWARE, null); } else { mWebView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); }
Try these and check if your content is loading faster in Android WebView.
Please send your comments to coderzheaven@gmail.com.
This is gold, even in 2018. I used some of those (the ones I could easily implement at NativeScript) and the change was notorious. A million thanks.
where should i write this code in my app source code..could you please tell using screenshots
What a genius you are.. For once i though i made a mistake using webview for large products list and i should have gone native but with your settings, its as good as native now.
Not only this, profiler shows atleast 60% reduction in memory utilization. I think saving DOM is doing the magic.. 3 cheers for your… Cheers !! Cheers !! Cheers !!!!
where should i write this code in my app source code..could you please tell using screenshots
This code will go to the place where you initialize your webview.
It really help improve my webview performance, Thanks alot ~~
Glad to hear that.