I have a custom list view and I'm currently trying to perform a custom behaviour for when the list view is over-scrolled (i.e., pushed beyond its bounds).
Everything is working perfectly, except that over-scroll only seems to work if the user drags or flings the list view when it's already at its limit. This means that if a user does a strong fling when the list is at the 1st element, the list will stop scrolling abruptly when reaching the last element, and only then if the user flings or drags down, the over-scroll functionality kicks in.
I'm trying to make the over-scroll work properly for the strong fling from the top of the list. The behaviour is very strange, since I can see that the "overScrollBy
" method is being called a couple of times with correct deltaY
values, but the scrollY
stay at 0.
I've been looking for a solution for this online for a while but I have not found any material on it.
Here is my overScrollBy
implementation:
@Override
protected boolean overScrollBy(int deltaX, int deltaY, int scrollX, int scrollY, int scrollRangeX, int scrollRangeY, int maxOverScrollX, int maxOverScrollY, boolean isTouchEvent)
{
if (!isTouchEvent)
{
deltaY = -scrollY / 10;
if (Math.abs(deltaY) <= 1)
deltaY = -scrollY;
}
if (mInPreviewMode && scrollY <= 0)
{
mSPListContainer.onOverScroll((float)Math.abs(scrollY) / (float)mMaxYOverscrollDistance);
}
super.overScrollBy(deltaX, deltaY, scrollX, scrollY, scrollRangeX, scrollRangeY, maxOverScrollX, mMaxYOverscrollDistance, isTouchEvent);
return true;
}