'How can I ignore the remaining screen to show other rows? Recyclerview

The Row

<androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginHorizontal="10dp"
        android:layout_marginVertical="2.5dp">

        <com.google.android.material.card.MaterialCardView
            android:layout_width="0dp"
            android:layout_height="0dp"
            app:layout_constraintDimensionRatio="1:1"
            app:layout_constraintWidth_percent="0.5"
            tools:ignore="MissingConstraints">

            <ImageView
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

        </com.google.android.material.card.MaterialCardView>

</androidx.constraintlayout.widget.ConstraintLayout>

I want every row to take 50% from the screen and everything works well but the remaining screen will be empty because I set ConstraintLayout as match_parent I tried to change it to wrap_content but not working.

How can I ignore the remaining screen to show other rows?

The problem is something like this



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source