i'm using firebase database to list items in recycler view, and i want two items to be on the same line like this:
but for me it's displaying like this this is my cardview list layout
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_marginTop="20dp"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
app:cardElevation="15dp"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/product_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Product Name"
android:textAlignment="center"
android:textSize="20sp"
android:textStyle="bold"
android:textColor="@color/design_default_color_primary_dark"/>
<ImageView
android:id="@+id/product_image"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_below="@+id/product_name"
android:scaleType="centerCrop"
android:layout_marginTop="2dp"/>
<TextView
android:id="@+id/product_price"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Product Price"
android:textAlignment="center"
android:textSize="18sp"
android:textStyle="bold"
android:layout_below="@id/product_image"
android:textColor="@color/design_default_color_primary_dark"/>
<TextView
android:id="@+id/product_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Product Description"
android:textAlignment="center"
android:textSize="16sp"
android:textStyle="bold"
android:layout_marginTop="2dp"
android:layout_below="@id/product_price"
android:textColor="@color/design_default_color_primary_dark"/>
</RelativeLayout>
</androidx.cardview.widget.CardView>
i want to make it so somehow instead of only one showing up in a line in recyclerview i want mutiple ones to appear
Use grid layout manager for ReccyclerView with 2 as second parameter, for showing 2 columns.
RecyclerView.LayoutManager mLayoutManager = new GridLayoutManager(this, 2);
recyclerView.setLayoutManager(mLayoutManager);