Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android BottomSheet with RecyclerView

I added a BottomSheet with a RecyclerView in it to my app, but I can't scroll the RecyclerView, and I can't find out what is the problem.

Here is my BottomSheet:

   <!-- bottom sheet -->
<FrameLayout
   android:id="@+id/bottom_sheet"
   style="@style/Widget.Design.BottomSheet.Modal"
   android:layout_width="match_parent"
   android:layout_height="0dp"
   app:behavior_hideable="true"
   app:behavior_peekHeight="90dp"
   app:layout_behavior="@string/bottom_sheet_behavior">

    <!-- horizontal thumbnail -->
    <android.support.v7.widget.RecyclerView
       android:id="@+id/horizontal_thumbnail"
       android:layout_width="match_parent"
       android:layout_height="90dp"/>

    <!-- vertical thumbnail -->
    <android.support.v7.widget.RecyclerView
       android:id="@+id/vertical_thumbnail"
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       android:visibility="gone"/>
</FrameLayout>

The vertical thumbnail is visible when the sheet is expanded, the horizontal is visible when the list is collapsed.

like image 532
user3057944 Avatar asked Nov 24 '16 15:11

user3057944


2 Answers

Also you can put the RecyclerView inside NestedScrollView.

like image 152
Gentle Avatar answered Nov 10 '22 16:11

Gentle


Solved it. The problem was I added two RecyclerViews to the BottomSheet, and the second one didn't scroll in this case. I don't really need the first when and when I removed it, I was able to scroll the other.

like image 22
user3057944 Avatar answered Nov 10 '22 14:11

user3057944