Detect if Webview scroll reach the end
Solution 1
ok, i figured out the answer
you can get the real content height using
(int) Math.floor(webView.getContentHeight() * webView.getScale());
when you get the real height, then just override the scroll method in webview to listen to scroll event, if the scroll reach the real height, your webview is in the bottom of the scroll.
Solution 2
@Override
public void onScroll(int l, int t) {
int height = (int) Math.floor(webView.getContentHeight() * webView.getScale());
int webViewHeight = webView.getHeight();
int cutoff = height - webViewHeight - 10; // Don't be too strict on the cutoff point
if (t >= cutoff) {
setDisclaimerButtonEnabled(true);
}
}
The non-strictness is required, is because I found on the Samsung S5 the bottom most scroll value was only 1 pixel value away from the bottom most value!
Mohammad Ersan
Updated on June 04, 2022Comments
-
Mohammad Ersan almost 2 years
am trying to figure out the max scroll position that the
WebView
can reach, i've tried thewebView.pageDown(true)
but the result is delayed ( i cant scroll it down, then up infront of the user, and this method doesn't work every time), i've tried alsowebView.getContentHeight()
and the height isn't correct for Arabic content.Please Advice