2

I have made a view with horizontal RecyclerView in CoordinatorLayout such that the parent of RecyclerView is appbar_scrolling_view_behavior . Everything works perfect except when we try scrolling vertically on the recyclerView. Is there a way we can scroll vertically while scrolling on Y axis and horizontally on X axis.

EDIT

There are two RecyclerView in fragment which is ultimately used in CoordinatorLayout . Now first recyclerView is horizontal and second is vertical. When I scroll horizontally on first RecyclerView it works perfectly and when I scroll vertically on second RecyclerView it works perfect. Now the problem is when I try to scroll vertically over first RecyclerView parent scroll should work. Thanks.

Tom11
  • 2,419
  • 8
  • 30
  • 56
Navdroid
  • 1,541
  • 3
  • 25
  • 52

1 Answers1

0

Yes, this is easy to do, checking scroll state of everyone RecycleView. So, as example, you have on one Fragment - 5 different orientation RecycleViews. And you want scroll all, when scroll some one from them.

1) Setup onScrollChangeListener on every RecycleView.

mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() 
{
    @Override
    public void onScrolled(RecyclerView recyclerView, int dx, int dy) 
    {
        mRecycle1.smoothScrollBy(dx, dy); // Or use any other behaviour 
        mRecycle2.smoothScrollBy(dx, dy); 
        mRecycle3.smoothScrollBy(dx, dy); 
        ......
    }
}

EDIT:

This is works fine for any axes(X and Y). Check also this link about RecycleView scrolling state.

Community
  • 1
  • 1
GensaGames
  • 5,538
  • 4
  • 24
  • 53
  • not working in my case..onScrolled is called only when scrolled in x axis...not for y in horizontal RecyclerView. – Navdroid Apr 22 '16 at 08:42