I am trying to stop my scrollview scrolling when it reaches a scrollY position. Then, change it back to scrollable when children view (recyclerview) reach the top or overscrolled.
I tried two methods
- onTouchListener - it doesn't interact with scrollY position
nestedScrollView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
return false;
}
});
- setOnScrollChangeListener - don't know how to set it as non-scrollable
nestedScrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
@Override
public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
if (scrollY >400dp) {
}
}
Edit 1 XML
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<Linearlayout
android:layout_width="match_parent"
android:layout_height="match_parent">
//include more contents card
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:nestedScrollingEnabled="true"
android:orientation="vertical"
/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>