Important Steps to improve WebView Performance in Android

Important Steps to improve WebView Performance in Android

Important Steps to improve WebView Performance in Android

<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);
}