Scroll behavior in nested RecyclerView with horizontal scroll

后端 未结 3 636
深忆病人
深忆病人 2020-12-13 18:36

I have to create vertical RecyclerView with nested horizontal RecyclerView in every item. Everything is within CoordinatorLayout. When

相关标签:
3条回答
  • 2020-12-13 18:48

    We can achieve this in XML

    android:nestedScrollingEnabled="false"
    
    0 讨论(0)
  • 2020-12-13 19:11

    Try with RecyclerView inside android.support.v4.widget.NestedScrollView.

    <android.support.v4.widget.NestedScrollView
            android:id="@+id/nScrollView"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
    
    <!-- Set other views of your Layout -->
    
    </android.support.v4.widget.NestedScrollView>
    

    Also try with different layout_scrollFlags in Toolbar and

    RecylerView.setNestedScrollingEnabled(false); // set it true or false as per requirement
    
    0 讨论(0)
  • 2020-12-13 19:13

    As requested here is the solution I found good enough so far:

    In my case I have a nestedScrollView with 4 RecyclerViews set to scroll horizontally inside. For each of those RecyclerViews I have done this programatically:

    restaurantsRecylerView.setHasFixedSize(true); 
    restaurantsRecylerView.setNestedScrollingEnabled(false);
    

    You probably don't want the fixedSize, not sure if it will make any difference, my list is always 25 so I can use that for performance. After having done this I can scroll without issues even when I touch on the recyclerViews

    Hope it helps

    0 讨论(0)
提交回复
热议问题