NestedScrollView’s smoothScrollTo() behaves weird

Looks like there is a bug when programmatically scrolling NestedScrollView within CoordinatorLayout. This solved my problem:

private void scrollToView(final View view) {
    mScroller.scrollBy(0, 1);
    mScroller.smoothScrollTo(0, view.getTop());
}

or for better control:

private void scrollToView(final View view) {
    mScroller.scrollBy(0, 1);
    ObjectAnimator.ofInt(mScroller, "scrollY",  view.getTop()).setDuration(700).start();
}

Leave a Comment