How to reduce the load time of android webview?

4.2k views Asked by At

I am developing a hybrid android app, where each click on the link opens a new activity with a new webview. The Android webview takes a lot of time to load even if the resource are cached in the local directory. I want to reduce this time as much as possible to give a good user experience.

The things that I have tried so far -

  1. WebSettings

    settings.setRenderPriority(WebSettings.RenderPriority.HIGH)
    
  2. Webview LayerType

    if (Build.VERSION.SDK_INT >= 19) {
        webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
    } else {
       webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }
    
  3. Hardware Acceleration

    <application android:hardwareAccelerated="true" ...>
    

Some other popular companies that have hybrid apps are Amazon & Quora. But they use third party libraries. However I am interested in knowing how can we achieve the same speed with android webview.

2

There are 2 answers

0
Fady Sadek On

You should have a look onto project cross walk it is a web view made specifically for building cross platform hybrid apps although it's size is kind of big it will save you a lot of time targeting different web views since you are coding and testing using just one browser which is the cross walk's webview

0
marcinj On

You may put your WebView into a fragment then preload this fragment on activity start but as hidden. Then when needed show it with new content. This eliminates load time of webview but not the content of it.