3

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;
    }
Gil Moshayof
  • 16,633
  • 4
  • 47
  • 58
  • Hey i'm facing same issue have u find any result with this? – Antwan Aug 18 '15 at 01:20
  • Not really, just accepted that this is the behavioural pattern for android. – Gil Moshayof Aug 18 '15 at 07:23
  • Also, perhaps consider dropping listview all together and upgrading to recyclerview? You can create your own layout manager and implement your own overscroll logic. I've done this for a different feature and it works well. Couldn't get list view to behave this way tho. – Gil Moshayof Aug 18 '15 at 07:52
  • Thanks for fast response could you please post recycle view code for this functionallity – Antwan Aug 18 '15 at 08:16
  • here is my question of you like to share some code :) http://stackoverflow.com/questions/32055580/how-to-create-pull-from-botom-scroll-view-or-list-view-android – Antwan Aug 18 '15 at 08:30

0 Answers0