<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/PetPhoto_imageview"
android:layout_width="200dp"
android:layout_height="200dp"
app:layout_constraintBottom_toTopOf="@+id/PetItem_textview"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed"
app:srcCompat="@drawable/dog" />
<TextView
android:id="@+id/PetItem_textview"
android:layout_width="199dp"
android:layout_height="38dp"
android:layout_alignBottom="@+id/PetPhoto_imageview"
android:layout_alignParentStart="true"
android:layout_marginStart="0dp"
android:alpha="0.3"
android:background="@color/black"
android:gravity="bottom"
android:textAlignment="center"
android:textColor="@color/white"
android:textSize="20sp"
android:textStyle="bold"
tools:text="100" />
</RelativeLayout>
</android.support.v7.widget.CardView>
Those are my layout files, then picture below was they look like now, I want to set those pictures in two columns.
Set from xml
file add two property in RecyclerView
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
app:spanCount="2"
If i understand correctly, you want to have the items in your recyclerview able to show in two columns. Try adding this when you set layoutManager
recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With