If you really want to keep the TextView separate from the RecyclerView, wrap them in a NestedScrollView
instead:
<NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView />
<RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
</NestedScrollView>
When you set up your RecyclerView, you will probably want to call RecyclerView#setNestedScrollingEnabled(false)
otherwise the RV may consume some scrolling inside the parent (which you don't want).
NOTE: This approach makes the tradeoff that the RV will be forced to layout all of its views, losing the recycling benefit. The correct approach would be to properly dedicate a viewType
to the RV for this header TextView and not deal with wrapping it inside additional ViewGroups.