I have overridden overScrollBy
method in ScrollView
based on the following post:
http://jasonfry.co.uk/blog/android-overscroll-revisited/
It is working fine on other platform version, but Lollipop is unable to bounce back if fling motion is applied to the ScrollView
.
Anyone encountered this issue and found a workaround?
Called in constructorsetOverScrollMode(OVER_SCROLL_ALWAYS);
Here relevant code which I have overridden in my custom ScrollView
class:
@Override
protected boolean overScrollBy(int deltaX, int deltaY, int scrollX,
int scrollY, int scrollRangeX, int scrollRangeY,
int maxOverScrollX, int maxOverScrollY, boolean isTouchEvent) {
return super.overScrollBy(deltaX, deltaY, scrollX, scrollY,
scrollRangeX, scrollRangeY, maxOverScrollX, OVER_SCROLL_AMOUNT,
isTouchEvent);
}
Thanks.
I digged into changes between KitKat an Lollipop ScrollView
. Following code solves my issue.
@TargetApi(21)
@Override
public boolean dispatchNestedFling(float velocityX, float velocityY, boolean consumed) {
// Not consumed means it wasn't handled because ScrollView
// doesn't take over scrolling bounds into scroll range,
// so we fling it ourselves to get it bounce back
if (getOverScrollMode() == OVER_SCROLL_ALWAYS && !consumed) {
fling((int) velocityY);
return true;
} else {
return super.dispatchNestedFling(velocityX, velocityY, consumed);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With