RecyclerView Inside CardView Not Scrolling Properly in Kotlin App

I am new in Android Application development with kotlin and I am creating an Android app where I display categories, each with a RecyclerView to show a list of items. The RecyclerView is nested inside a CardView. However, when there are many items in the RecyclerView, the items are not scrolling properly which is inside of the cardview. If the item lists exceeds the size of recycler view then it does not scroll.

In the code below the RecyclerView with id rvItems does not make the contents in it to scroll even if the list is more and exceeds the height of cardview.

Here is the XML layout for the category card:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <androidx.cardview.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="500dp"
        android:layout_margin="10dp"
        android:backgroundTint="@color/design_default_color_secondary"
        android:padding="10dp"
        app:cardCornerRadius="15sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:padding="5dp">

            <ImageView
                android:id="@+id/imgMenu"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="10dp"
                android:src="@drawable/baseline_menu_24"
                app:layout_constraintBottom_toBottomOf="@+id/tvCategoryTitle"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="@id/tvCategoryTitle" />

            <TextView
                android:id="@+id/tvCategoryTitle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="20sp"
                android:layout_marginTop="5dp"
                android:text="Category"
                android:textColor="@color/black"
                android:textSize="20sp"
                android:textStyle="bold"
                app:layout_constraintStart_toEndOf="@+id/imgMenu"
                app:layout_constraintTop_toTopOf="parent" />

            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/rvItems"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_marginTop="8dp"
                android:padding="5dp"
                app:layout_constraintTop_toBottomOf="@+id/tvCategoryTitle"
                app:layout_constraintBottom_toBottomOf="parent"
                tools:listitem="@layout/item_item" />

        </androidx.constraintlayout.widget.ConstraintLayout>

    </androidx.cardview.widget.CardView>

</androidx.constraintlayout.widget.ConstraintLayout>

There is only one RecyclerView in my main xml where I want to show all the data, and item xml is given below:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <androidx.cardview.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:padding="8dp"
        app:cardCornerRadius="10dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:padding="10dp">

            <TextView
                android:id="@+id/tvItem"
                android:layout_width="0dp"
                android:layout_marginStart="8dp"
                android:layout_height="wrap_content"
                android:text="Sub Item"
                android:textColor="@color/black"
                android:textSize="18sp"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toStartOf="@+id/imgShare"/>

            <ImageView
                android:id="@+id/imgShare"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/baseline_share_24"
                android:layout_marginEnd="10dp"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"/>

        </androidx.constraintlayout.widget.ConstraintLayout>

    </androidx.cardview.widget.CardView>

</androidx.constraintlayout.widget.ConstraintLayout>

Any help is appreciated. Thank you!