Start scrolling at a given position

I would like to start the drop effect at the given start and end positions (default for content) instead of 0 and height.

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

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

@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 that I can set the number of pixels I want to skip by changing the maxOverScrollY (as shown above), but I couldn't find the hook. The code in the view is quite long, so if anyone knows the mechanism how this works, any help is appreciated.

What do I want to achieve and why do I need it? I have a view that I can scale to zoom in and out. This view is inside two scrolling views, and I want to set the scrolling constraints based on the scale. So when the scale is set to 100% the scrolling starts at 0 and the height, if the scale is set to 50% my view only takes 50% of the view, so I want to set the scrolling limits to 25% and 75%.

+3


source to share





All Articles