I have a recyclerView where I need to show only images from API with pagination(Paging3 library). I have to show the image with StaggeredGridLayout.I specify the span count 3 and the item layout width, and height to wrap content. But it wasn't working. I want a second item layout whichh is double size. I have attached a snap that I want as my layout. Please help me, I am stuck. What I want This is the screenshot I want to make
RecylerView
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/searchHomeImageRv"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_margin="7dp"
android:orientation="vertical"
app:layoutManager="androidx.recyclerview.widget.StaggeredGridLayoutManager"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/appBarLayout2"
app:spanCount="3"
tools:listitem="@layout/row_image" />
Item CardLayout
<com.google.android.material.card.MaterialCardView 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_margin="2dp"
android:clickable="true"
android:focusable="true"
app:cardCornerRadius="5dp"
app:cardElevation="5dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:rippleColor="@color/black500">
<ImageView
android:id="@+id/img"
android:layout_width="match_parent"
android:layout_height="200dp"
android:scaleType="centerCrop"
android:src="@drawable/attention" />
</com.google.android.material.card.MaterialCardView>