I had a similar problem. The design support library is a great library, but at the moment itβs a bit buggy. Here you can find some problems regarding NestedScrollView: Problems with NestedScrollView . We will have to wait for the next updates until we have a fully working library.
Until then, you can try several alternative libraries, for example: ObservableScrollView .
It is quite simple to use:
1 - add the dependency to the build.gradle file:
repositories { mavenCentral() } dependencies {
2 - In the layout, declare ObservableScrollView as:
<com.github.ksoichiro.android.observablescrollview.ObservableListView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/list" android:layout_width="match_parent" android:layout_height="match_parent" />
3 - Implement ObservableScrollViewCallbacks in your activity:
public class MainActivity extends AppCompatActivity implements ObservableScrollViewCallbacks {
4 - Implement the necessary methods and play with them:
@Override public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) { } @Override public void onDownMotionEvent() { } @Override public void onUpOrCancelMotionEvent(ScrollState scrollState) { }
5 - An example of showing / hiding an ActionBar when scrolling through a list:
@Override public void onUpOrCancelMotionEvent(ScrollState scrollState) { ActionBar ab = getSupportActionBar(); if (scrollState == ScrollState.UP) { if (ab.isShowing()) { ab.hide(); } } else if (scrollState == ScrollState.DOWN) { if (!ab.isShowing()) { ab.show(); } } }
Hope this helps.
source share