Google Play商店(如界面)使用回收站视图 [英] Google play store like interface using recycler view
问题描述
我的任务是创建一个与Google Play商店非常相似的界面.将有一个类别名称,后跟3或4张卡(水平),然后是更多按钮.然后是下一个类别.
My assignment is to create an interface much same like Google Play Store.There will a Category name followed by 3 or 4 cards (horizontal) followed by More button. Then again next category.
我已经通过将水平"列表嵌套在垂直"列表视图中来实现此目的.
I already had implemented this using nesting the horizontal listview inside Vertical listview.
我知道,我可以通过将Recycler视图与LinearLayoutManager一起使用来实现此目的,该视图具有水平方向.使用这个,我将只有一行.
I know, I can achieve this by using the Recycler view with LinearLayoutManager with horizontal orientation. Using this I'll be having one only row.
我的问题是如何在此添加第二行,第三行? 我是否应该再次使用嵌套的Recycler视图? 有更好的选择吗?
My question is how do I add 2nd, 3rd row to this? Should I use again nested Recycler view? Are there some better options?
推荐答案
不要使用嵌套的列表视图(您不能在Play商店中水平滚动).
Dont use nested listviews (you cant scroll horizontally in play store).
请考虑以下选项:
- 您可以使用简单的LinearLayoutManager并创建不同的视图类型.对于水平放置3张卡片的,使用权重相同的
GridLayout
或LinearLayout
.这里的问题是,您必须考虑适配器中使用的基础数据列表的索引 - 为RecyclerView编写自己的LayoutManager
- 使用双向视图,该视图基于RecyclerView,并提供
Spannable Grid
布局管理器,该管理器似乎正是您想要的.
- You can use a simple LinearLayoutManager and make different view types. For the with 3 cards horizontally use a
GridLayout
orLinearLayout
with same weights. The problem here is, that you have to consider the indexes of your underlying data list used in the adapter - Write your own LayoutManager for RecyclerView
- Use TwoWay View which is based on RecyclerView and offers a
Spannable Grid
Layout manager, which seems to be what you are looking for.
这篇关于Google Play商店(如界面)使用回收站视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!