I need RecyclerView to scroll (this is all right), but TextView is not, i.e. it always remains at the top bottom sheet. Here is the xml of this snippet:

<android.support.v4.widget.NestedScrollView android:id="@+id/bottom_sheet" android:layout_width="match_parent" android:layout_height="250dp" android:fillViewport="true" android:background="#898989" app:layout_behavior="android.support.design.widget.BottomSheetBehavior"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <TextView android:id="@+id/textViewR" android:layout_width="50dp" android:layout_height="50dp" android:text="dgd" android:gravity="center" android:textColor="#fff" /> <android.support.v7.widget.RecyclerView android:id="@+id/recyclerView" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="8dp" android:orientation="vertical" android:layout_weight="1" android:paddingBottom="15dp" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" /> </LinearLayout> </android.support.v4.widget.NestedScrollView> 

Thank you for your help!

  • 2
    Well, just pull out the TextView from ScrollView . - eugeneek
  • and where to go? - Vlad Sapozhnikov
  • For example, make the root a vertical LinearLayout in which your TextView will go first, followed by ScrollView . - eugeneek
  • I still don't understand, I have a bottom panel of a Nested Scroll View and it can contain only one element. And there's nowhere more to put a TextView - Vlad Sapozhnikov

1 answer 1

Once you use RecyclerView , then the additional NestedScrollView is not needed here at all. Use the following markup:

 <LinearLayout android:id="@+id/bottom_sheet" android:layout_width="match_parent" android:layout_height="250dp" android:fillViewport="true" android:background="#898989" android:orientation="vertical" app:layout_behavior="android.support.design.widget.BottomSheetBehavior"> <TextView android:id="@+id/textViewR" android:layout_width="50dp" android:layout_height="50dp" android:text="dgd" android:gravity="center" android:textColor="#fff" /> <android.support.v7.widget.RecyclerView android:id="@+id/recyclerView" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="8dp" android:orientation="vertical" android:layout_weight="1" android:paddingBottom="15dp" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" /> </LinearLayout>