I'm trying to make a webView "bounce" when pulled after scroll reached the max (kind of like the "pull-to-refresh" effect).
I have my custom view extending WebView, and overriding the method
@Override
protected boolean overScrollBy(final int deltaX, final int deltaY, final int scrollX, final int scrollY, final int scrollRangeX, final int scrollRangeY, final int maxOverScrollX, final int maxOverScrollY, final boolean isTouchEvent)
{
VerticalOverScrollController.Result result = overscrollController.calcVerticalOverScroll(deltaY, scrollY);
Log.d("overScrollBy", "scrollY " + result.scrollY + " overScrollY " + result.overScrollY);
return super.overScrollBy(deltaX, deltaY, scrollX, result.getScrollY(), scrollRangeX, scrollRangeY, maxOverScrollX, result.getOverScrollY(), isTouchEvent);
}
and calcVerticalOverScroll is
public Result calcVerticalOverScroll(final int deltaY, final int scrollY)
{
Result result = new Result();
if (scrollY <= 0 && deltaY < 0)//if at top and pulling down...
{
result.scrollY = (maxTopOverScroll > 0) ? scrollY : 0;
result.overScrollY = maxTopOverScroll;
} else
{
result.scrollY = (maxBottomOverScroll > 0) ? scrollY : 0;
result.overScrollY = maxBottomOverScroll;
}
return result;
}
and Result is just
public static class Result
{
int scrollY;
int overScrollY;
... getters()
}
The thing is, this works perfectly on any view (including webview) before KitKat.
After KitKat this works perfectly on any view except WebView, where the log for scrollY is always 0.
Any ideas on what could have changed on this version of the WebView?
If this does not fly, any ideas on how to achieve the overScroll effect on a WebView correctly?
Thanks in Advance.