I use recyclerview inside a nestedscrollview as follows:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
android:id="@+id/mainScrollView"
android:layout_marginBottom="?attr/actionBarSize"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="fill_parent"
android:overScrollMode="never"
android:layout_height="250dp"
android:focusableInTouchMode="true"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/VerticalRV"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
The problem is that when I want to set a listener (onScrollListener
) to this recycler view, it doesn't get working anyway. I also have debugged this piece of code, but it doesn't even catch the event. Below is the java code:
recyclerView.setNestedScrollingEnabled(false);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(layoutManager);
MyAdapter adapter = new MyAdapter(verticalShownData, this.getActivity());
recyclerView.setAdapter(adapter);
recyclerView.addOnScrollListener(new HideShowScrollListener() {
@Override
public void onHide() {
animateCallback.animateHide();
}
@Override
public void onShow() {
animateCallback.animateShow();
}
});
How can I get this listener working? Thanks in advance.