RecyclerView with GridLayout

Example:

                                    
                                      <!-- activity_main.xml -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

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

</RelativeLayout>

<!-- custom_recycler_grid.xml -->
<LinearLayout 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:orientation="vertical"
android:padding="6dp">

<androidx.cardview.widget.CardView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:cardCornerRadius="10dp"
    app:contentPadding="6dp"
    android:layout_margin="4dp"
    android:scrollbars="vertical"
    android:focusable="true">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="8dp"
        android:orientation="vertical"
        android:gravity="center">

        <ImageView
            android:id="@+id/image"
            android:layout_width="70dp"
            android:layout_height="70dp"
            android:layout_marginBottom="10dp" />

        <TextView
            android:id="@+id/name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentStart="true"
            android:text="Text"
            android:textStyle="bold"
            android:padding="3dp"
            android:textColor="@color/colorPrimaryDark" />

    </LinearLayout>

</androidx.cardview.widget.CardView>

</LinearLayout>