Mine is a native app where I want to show/ hide a button if the user scrolls to the end of webview. I looked at an answer here and got the entire idea of how to register the callback via interface. My major issue is that I am not able to get my calculations right inside the onScrollChanged method. I have tried combination of things like getHeight(), getContentHeight(), top etc but it just seems to fire too early. I tried with a simple page like google's with comparatively lesser content as well as a news page.
These logics work fine for a normal scroll view. Since the webpage has a lot of content, it could be messing up the calculations. Pasting a sample code: does not work.
@Override
protected void onScrollChanged(int left, int top, int oldLeft, int oldTop) {
if ( mOnWebViewBottomReachedListener != null ) {
//if ( (getContentHeight() - (top + getHeight())) <= mMinDistance )
int diff = (getBottom() - (getHeight() + getScrollY()));
Log.e("values ", diff+" o");
if ((int) Math.floor(getContentHeight() * getScaleY()) == top)
mOnWebViewBottomReachedListener.onBottomReached(this);
}
super.onScrollChanged(left, top, oldLeft, oldTop);
}
Need help with this. Thanks.