0

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

Taha Sami
  • 1,565
  • 1
  • 16
  • 43
  • 1
    Please see this answer https://stackoverflow.com/questions/38653406/make-width-of-horizontal-recycler-view-items-70-of-screen-width – Aldrin Joe Mathew Feb 13 '22 at 08:10
  • @AldrinJoeMathew Thanks for your reply, I know how to do it programmatically but I asked because maybe there is a way to do it via XML itself without Java code. – Taha Sami Feb 13 '22 at 08:20

0 Answers0