Android RecyclerView项目动态布局

问题描述 投票:0回答:2

在我的回收站视图项目布局中,我想添加类似水平的回收站视图布局的内容,因为我不知道需要多少ImageView,这就是为什么我不能将它们创建为静态布局的原因。图标的数量取决于服务器逻辑。如何实现下面的picutre之类的东西?预先谢谢!

enter image description here

java android android-layout android-recyclerview android-imageview
2个回答
0
投票

0
投票
类似

假设这是主Recyclerview

<androidx.recyclerview.widget.RecyclerView android:id="@+id/mainRecyclerview" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" tools:listitem="@layout/item_demo" />

[在您的子布局中,假设item_demo您必须为要水平显示的imageView添加另一个Recyclerview

<androidx.recyclerview.widget.RecyclerView
                        android:id="@+id/mainRecyclerview"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal"
                        tools:listitem="@layout/item_child" />

[item_child布局包含将水平显示的Imageview

© www.soinside.com 2019 - 2024. All rights reserved.