Android ListView over-scroll during navigation

I have my own list view and I am currently trying to do custom behavior when the list view is reprogrammed (i.e. pushed out of bounds).

Everything works fine, except that over-scrolling only works if the user drags or moves the list view when he is already at his limit. This means that if the user makes a strong jump when the list is in the 1st item, the list will stop scrolling when the last item is reached, and only if the user flips or drags down, the overscrolling function will be executed.

I am trying to get overscrolling to work properly for a strong throw from the top of the list. The behavior is very strange as I can see that the method is " overScrollBy

" called a couple of times with the correct values deltaY

, but scrollY

remains at 0.

I've been looking for a solution for this online for a while, but I haven't found any material on it.

Here is my implementation overScrollBy

:

@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;
    }

      

+3


source to share





All Articles