0

Since loading a large html in android webview is very slow. I would like to load it partially and as user scrolls down I load the rest.

I am using

webview.loadDataWithBaseURL("file:///android_asset/css/",
                    htmlString, "text/html", "UTF-8", null);

and I know I can use

webview.setOnScrollChangeListener(new View.OnScrollChangeListener() {
                @Override
                public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {

                }
            });

but I do not know how to append the rest of html as user scrolls.

I do not want to keep loading the whole page as user scrolls

Omid Aminiva
  • 667
  • 5
  • 14

1 Answers1

0

Seems like there is no way to load html partly , because when u call

webview.loadDataWithBaseURL("file:///android_asset/css/",
                htmlString, "text/html", "UTF-8", null);

or

webview.loadUrl("http://www.google.com");

your webView loads the entire html file, so I think u should show some animation with spinner while loading will not be completed, like here:

mWebView.setWebViewClient(new WebViewClient() {
    public void onPageFinished(WebView view, String url) {
        // Hide your spinner 
    }
});
Hayk Petrosyan
  • 363
  • 1
  • 6