RecyclerView 的自定义网格布局 Android
Custom Grid Layout for RecyclerView Android
我需要这样的网格布局构建。
我已经创建了 RecyclerView 并设置了 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>
但它生成空 space。请帮我实现这个目标。
您要找的是 StaggeredGridLayout
试试这个 -
StaggeredGridLayoutManager gridLayoutManager;
gridLayoutManager = new StaggeredGridLayoutManager(3, 1);
recyclerView.setLayoutManager(gaggeredGridLayoutManager);
希望对您有所帮助!
我需要这样的网格布局构建。
我已经创建了 RecyclerView 并设置了 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>
但它生成空 space。请帮我实现这个目标。
您要找的是 StaggeredGridLayout
试试这个 -
StaggeredGridLayoutManager gridLayoutManager;
gridLayoutManager = new StaggeredGridLayoutManager(3, 1);
recyclerView.setLayoutManager(gaggeredGridLayoutManager);
希望对您有所帮助!