0

My Recyclerview item occupies the whole screen height and width. I wish to implement a custom scroll inside the Recyclerview such that it scrolls only one item at a time ( similar to News In Shorts app ).

Thanks in advance!!

2 Answers2

4

You need to add just two below Lines

RecylerView mRecylerView = (RecylerView).findViewById(R.id.mRecylerView)
SnapHelper mSnapHelper = new PagerSnapHelper();
mSnapHelper.attachToRecyclerView(mRecylerView);

SnapHelper can be used to snap the child to any imaginary point or any pixel on the screen

Chitra Nandpal
  • 413
  • 4
  • 24
0

Try this code

parentScrollView.setOnTouchListener(new View.OnTouchListener() {

    public boolean onTouch(View v, MotionEvent event) {

        findViewById(R.id.childScrollView).getParent().requestDisallowInterceptTouchEvent(false);
        return false;
    }
});
childScrollView.setOnTouchListener(new View.OnTouchListener() {

    public boolean onTouch(View v, MotionEvent event) {

        // Disallow the touch request for parent scroll on touch of
        // child view
        v.getParent().requestDisallowInterceptTouchEvent(true);
        return false;
    }
});
Luciano Rodríguez
  • 2,239
  • 3
  • 19
  • 32
Vishwajit Palankar
  • 3,033
  • 3
  • 28
  • 48
  • @Viswajit - Thanks for the response, but could you be more specific about how to implement this code and where. – Ganesh Kumar S Apr 24 '15 at 07:06
  • In my code am using LinearLayoutManager as am implementing linear scrolling of the list item. So do i have to override certain functions inside the LayoutManager.? – Ganesh Kumar S Apr 24 '15 at 07:09