How can I stop my recylcerview from squishing to fit the page?

55 Views Asked by At

I have a RelativeLayout activity. At the bottom of the activity is 2 RecyclerViews.

When the RecyclerViews have too many items in them, the bottom one will stop expanding as it hits the bottom of the screen. It still has all the items in it, but they are not visible unless one scrolls in that RecyclerView which the user probably wont think to do.

All the layout_height options lead to the same result (fill_parent, match_parent, wrap_content). If anyone can tell me what I am missing to make this work that would be great.

Here is the XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    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:orientation="vertical"
    tools:context=".MainActivity">

    <include
        android:id="@+id/toolbar"
        layout="@layout/toolbar" />

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="60dp"
        android:paddingHorizontal="10dp">

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <TextView
                android:id="@+id/textView7"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="List1"
                android:textStyle="normal"
                android:textSize="24sp"/>

            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/recyclerView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />

            <TextView
                android:id="@+id/textView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="List2"
                android:textStyle="normal"
                android:textSize="24sp" />

            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/recyclerView2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />
            
        </LinearLayout>

    </ScrollView>

</RelativeLayout>

Here is an image of the problem, though it is still hard to see. Like I said in the description the second RecyclerView stops with the bottom of the screen and hides items in it that require the RecyclerView to be scrolled through to view.

0

There are 0 best solutions below