OnPageFinished in WebViewClient doesn't seem to work correctly

I saw another SO question on this, and it was not resolved.

I am using LoadData () with the html application created.

I noticed when I add a few empty lines after the new text, the page scrolls and the text appears magically for a moment (without scrolling, it just appears as when fading.).

The .getContentHeight () view is not updated in the onPageFinshed () event, but it is updated the next time text is added to the page.

I created a timer event to watch getContentHeight. Even after I discovered that getContentHeight had changed and released the browser .pageDown (true), the page still ran when scrolling down.

It seems to work fine the first time you enter the game. My problem only occurs when adding a few lines to newInnerHTML.

In addition, the view in question has a header and footer with a browser in the middle. WebView is NOT located behind the footer.

Is this a mistake, or am I missing something?

Tia, Jim

this code is inside onCreate for activity.

        final WebView browser = (WebView) findViewById(R.id.webview);
        browser.setWebViewClient(new WebViewClient() {  
            @Override  
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(browser, url);
              //  browser.computeScroll();  //didn't help
                Log.d(TAG,"page getContentHeight: " + browser.getContentHeight());
                Log.d(TAG,"page finished");
                browser.pageDown(true);
            }  
        });

This method after onCreate operation for activity

private void UpdateMessageDisplay () {

     //loadData fires onPageFinished but without the new data
     browser.loadData("<html><body>" + newInnerHTML + "</body></html>", "text/html", "utf-8");
     //reload() again fires onPageFinished but this time with new data
     browser.reload();

}
+3
source share
1 answer

I got a partial answer here that fires the page (true).

webview scroll scrolling setting not updating until click

There are some more problems.

+1
source

Source: https://habr.com/ru/post/1768155/


All Articles