我正在寻找一种方式,以显示一个列表的图像/图标的可变宽度在我的UI中,并启用行包装,这样可以有一个可变数量的对象每行。对象列表是动态的,来源于DB。我目前正在使用StaggeredGridLayout,但限制如下:
(见下面的截图)
我错过了什么重要的东西吗?也许我应该使用一个完全不同的构造(比如一个表),但是如果我遗漏了一些明显的东西,请告诉我。
RecyclerView XML:
<android.support.v7.widget.RecyclerView
android:id="@+id/tagsRecyclerView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:layout_marginHorizontal="8dp"
android:rotationY="180"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toEndOf="@+id/tagsTxt"
app:layout_constraintTop_toBottomOf="@+id/paragraphTxt" />使用以下方法初始化布局:
tagRecyclerLayoutManager = new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL);Current look (StaggeredGridLayout;网格扩展以填充所有空间,一致的列# (spanCount)):

所需的外观(行包装、一致间距、动态列#):

发布于 2019-02-08 22:16:09
你应该考虑一下FlexboxLayout。看看GitHub项目站点上的自述文件。我想你会发现它符合你的需要。还有一个用于FlexboxLayoutManager的RecyclerView。所有这些都得到了谷歌的支持。
您可以下载GitHub项目来播放它,看看是否可以使用它。谷歌游戏商店里也有一些游戏演示应用程序。去找就行了。
https://stackoverflow.com/questions/54599780
复制相似问题