I needed a Grid Layout build like this.
I have create RecyclerView and set GridLayoutManager
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/imgPost"
android:scaleType="centerCrop"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
But it generates empty space. Please help me achieve this.
What you're looking for is a StaggeredGridLayout
Try this -
StaggeredGridLayoutManager gridLayoutManager;
gridLayoutManager = new StaggeredGridLayoutManager(3, 1);
recyclerView.setLayoutManager(gaggeredGridLayoutManager);
Hope this helps!