NestedScrollView fling stopping bug on Nougat (API 25) NestedScrollView fling stopping bug on Nougat (API 25) android android

NestedScrollView fling stopping bug on Nougat (API 25)


So it's clearly a bug in NestedScrollView.I have made a workaround for this, but still waiting for a proper fix from Google side.

https://github.com/Dimezis/FlingableNestedScrollView/

Edit:

Looks like the issue is fixed in support lib 26.0.0-beta2

https://chris.banes.me/2017/06/09/carry-on-scrolling/

Edit 2:Although the scrolling works fine now, in my app I can constantly reproduce this bug:

https://issuetracker.google.com/issues/37051723

If someone encounters it as well, you can find a workaround in a thread mentioned.


according to Animating a Scroll Gesture training guide, while overriding computeScroll(), after using mScroller.computeScrollOffset() to calculate proper offset to scroll view, we need use:

ViewCompat.postInvalidateOnAnimation(this);

to animate next scroll.However, in the NestedScrollView, the computeScroll() looks like this:

public void computeScroll() {    if (mScroller.computeScrollOffset()) {    ...         }}

It doesn't request next scroll animation! Which means that after using mScroller.fling(...), the computeScroll() method will sometimes only get called one time, and view doesn't keep fling.

To fix this problem, I have tried to replace the computeScroll in this way:

public void computeScroll(){    if(mScroller.computeScrollOffset()){       ...       ViewCompat.postInvalidateOnAnimation(this);     }}

It may not sound a good solution, but it just works fine for now.

Recent version of NestedScrollView has added the ViewCompat.postInvalidateOnAnimation(this).