How to use androidx.recyclerview.widget.RecyclerView?

20 Views Asked by At

This's RecyclerView: enter image description here and this is CardView: enter image description here but design tab show me this: enter image description here I wanna try to this: enter image description here How I can fix it?

1

There are 1 best solutions below

0
Phyo Thiha Win On

As I checked on your question images, your RecyclerView item layout has taken full height of screen for each item. The problem is you set Cardview's layout_ height to "match_parent", that's why it takes full height.

Here you need to changes is,

<androidx.cardview.widget.CardView 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"> <!-- here you need to change wrap_content-->

...
...

</androidx.cardview.widget.CardView>