You need to nest RecyclerView in CardView, but in such cases the list will scroll inside CardView. How to make the list scroll with cardview? Those. stretch the map with the list to the full height of the content.

<?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v7.widget.CardView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="16dp"> <android.support.v7.widget.RecyclerView android:id="@+id/list" android:layout_width="match_parent" android:layout_height="wrap_content" app:layoutManager="LinearLayoutManager"/> </android.support.v7.widget.CardView> </ScrollView> 
  • it won't work out that way. the only thing you can do in cardview layout_height is to make match_parent - user239760

1 answer 1

You do not need ScrollView here - just remove it, and for CardView set the height to full screen - match_parent .

In general, nested scrolling containers are a bad practice. They still work somehow in the case of vertical + horizontal (with memory leaks that need to be repaired). When you want to do this, you need to stop and figure out how to avoid it in every possible way.