【发布时间】:2020-07-31 00:22:18
【问题描述】:
我创建了一个回收站视图,它的布局是使用交错网格布局管理的。但结果不平衡,谁能帮忙?
我所做的是:
val manager = StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL)
photoRv.layoutManager = manager
编辑 2020-08-02 这是我的项目布局
<layout 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">
<data>
</data>
<com.google.android.material.card.MaterialCardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:cardCornerRadius="10dp">
<ImageView
android:id="@+id/photo_iv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="centerInside"
tools:src="@drawable/img_haji" />
</com.google.android.material.card.MaterialCardView>
</layout>
这是包含回收站视图的底部表单布局
<layout 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">
<data>
</data>
<LinearLayout
android:id="@+id/gallery_bs"
style="@style/general_bottom_sheet">
<include layout="@layout/bottom_sheet_grip" />
<FrameLayout
style="@style/bottom_sheet_header_layout">
<include
android:id="@+id/close_btn"
layout="@layout/bottom_sheet_close_btn" />
<TextView
style="@style/bottom_sheet_title"
android:text="@string/gallery" />
</FrameLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/photo_rv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
tools:itemCount="4"
tools:listitem="@layout/service_gallery_bottom_sheet_item" />
</LinearLayout>
</layout>
【问题讨论】:
-
请添加您的项目布局说明
-
@MohammadOmidvar 感谢您的建议,我刚刚添加了它
-
你搞清楚这些东西了吗?我也有同样的问题。
标签: android android-recyclerview staggeredgridlayout