3

I would like to start the overscroll effect at given start and end positions (depoendent on the content), instead of 0 and height.

In other words: Let's say I have a ScrollView with overscroll enabled. When I scroll all the way up and y < 0, Android starts showing the edge effect. Dependent on the current content, I want to start the edge effect earlier. For example, I may want to set the lower limit to 100, which means that when y < 100 the edge effect is shown and the scroll view scrolled back to 100 (instead of 0).

I tried to override overScrollBy and it fires all the time when I scroll (being in overscroll or not), but I don't understand what the numbers actually do.

@Override protected boolean overScrollBy(int deltaX, int deltaY, int scrollX, int scrollY,
                                         int scrollRangeX, int scrollRangeY, int maxOverScrollX, int maxOverScrollY, boolean isTouchEvent) {
    System.out.println("deltaX = " + deltaX + ", deltaY = " + deltaY + ", scrollX = " + scrollX + ", scrollY = " + scrollY + ", 
            scrollRangeX = " + scrollRangeX + ", scrollRangeY = " + scrollRangeY + ", maxOverScrollX = " + maxOverScrollX + ", maxOverScrollY = " + maxOverScrollY + ", isTouchEvent = " + isTouchEvent);

    maxOverScrollY = 100;

    return super.overScrollBy(deltaX, deltaY, scrollX, scrollY,
            scrollRangeX, scrollRangeY, maxOverScrollX, maxOverScrollY, isTouchEvent);
}

I noticed I can set the amount of pixels I want to overscroll by changing maxOverScrollY (as shown above), but I could not find a hook. The code in View is quite lengthy, so if anybody knows the mechanism how this works, any help appreciated.

What do I want to achieve and why do I need that? I have a view which I can scale to zoom in and out. That view is inside two scroll views and I want to set the scroll limits dependent on the scale. So when scale is set to 100%, overscroll starts at 0 and height, if scale is set to 50%, my view only occupies the inner 50% of the view, so I want to set overscroll limits at 25% and 75%.

Oliver Hausler
  • 4,900
  • 4
  • 35
  • 70

0 Answers0