[英]Android RecyclerView item dynamic layout
Inside my recycler view item layout I want to add something like horizontal recyclerview layout, because I don't know how many ImageViews I need, that's why I can't create them as a static layout.在我的回收站视图项目布局中,我想添加类似水平回收站视图布局的内容,因为我不知道需要多少个 ImageView,这就是为什么我不能将它们创建为 static 布局的原因。 The number of icons depends on server logic.
图标的数量取决于服务器逻辑。 How can achieve something like the picutre below?
怎样才能实现像下面的图片? Thank you in advance!
先感谢您!
You Need Add Horizontal Recyclerview Inside The Main Recyclerview.您需要在主 Recyclerview 中添加水平 Recyclerview。 Your First RecyclerView is Verticle list and inside every index create another RecyclerView It's a Horizontal.
您的第一个 RecyclerView 是 Verticle 列表,并且在每个索引中创建另一个 RecyclerView 它是一个水平的。 so you can display n number of Imageview.
所以你可以显示n个Imageview。
You have to create Recyclerview inside the child layout of your main Recyclerview您必须在主 Recyclerview 的子布局中创建 Recyclerview
Something like就像是
Suppose this is the Main Recyclerview假设这是主要的 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" />
In your child layout, Let's say item_demo
you have to add another Recyclerview for the imageView that you want to show in horizontal在您的子布局中,假设
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
layout contains the Imageview that will display horizontally item_child
布局包含将水平显示的 Imageview
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.