this is because the onPageFinished means that WebView has finished reading bytes from the network, thatโs exactly what. When starting the onPageFinished point onPageFinished page cannot yet be parsed.
If your web view height is set to wrap_contents, you can do something like this:
WebView v = new WebView() { @Override public void onSizeChanged(int w, int h, int ow, int oh) { super.onSizeChanged(w, h, ow, oh);
If your webview is not wrap_contents, then one of the options is to do what josedlujan suggested in his answer to this question and get the height from JavaScript.
Another option is to use an obsolete PictureListener :
webview.setPictureListener(new PictureListener() { int previousHeight; @Override public void onNewPicture(WebView w, Picture p) { int height = w.getContentHeight(); if (previousHeight == height) return; previousHeight = height; Log.d(TAG, "WebView height" + height); } });
source share