Search code examples
androidscrollviewandroid-scrollview

Android overscroll for ScrollView


I asked before about OverScroll in ListView. Default overScroll doesn't work on many devices (for ex.: Samsung Galaxy 2, HTC One X). So I made OverScrollListView

But now needed to do the same for ScrollView. I made the trick for top overscroll (by using positive number in overScrollBy). But when i'm trying to do the same for bottom (by using a negative number in overScrollBy), overscroll ScrollView scrolling to top position.

Can someone say why?

P.S. I also tried this. But even in top (or bottom) position scrollbar indicator shown somewhere in middle. This confuse the user...


Solution

  • Ok, i think i did it.

    But it's really strange.

    I had method for overscroll that i call in ACTION_MOVE:

    private void pullDown(int deltaY, int lastY) {
        overScrollBy(0, mSlowEffect ? (int)getOverScrollYWithSlow(deltaY) : deltaY, 0, lastY, 5, 5, 0, mMaxYOverscrollDistance, true);
    }
    

    For ListView for overscroll i just set deltaY something like pullDown(lastScroll, 0);

    It works for both: top and bottom overscroll.

    But for ScrollView it doesn't work for bottom overscroll. So we should send to this method also current scrollY position, something like pullDown(lastScroll , lastY);

    I share whole code on Github, if someone interested.