Reputation: 1571
I have a CoordinatorLayout with a BottomSheet. Everything works fine if the Bottomsheet has only a RecyclerView. I tried to add some Textview and buttons on top of the RecyclerView, but the recyclerview scrolls beneath the other view when it reaches the top height. I want the other views to scrool too. If the BottomSheet contains only other views(without Recyclerview) works fine too. When I combine RecyclerView and other view elements (Button, TextView) the scrolling is not as expected.
I thought to set the views above Recyclerview as the first item of the list but this adds complexity to the adapter.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:behavior_hideable="false"
app:behavior_peekHeight="80dp"
app:layout_behavior="@string/bottom_sheet_behavior">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button 1"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Text 2"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Text 3"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:background="@android:color/white"
android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="true"/>
</LinearLayout>
Upvotes: 3
Views: 6335
Reputation: 1280
Use NestedScrollView as a parent of LinearLayout. It will solve your problem.
Upvotes: 6