如何使用RecyclerView创建此布局? [英] How to create this layout with a RecyclerView?

查看:72
本文介绍了如何使用RecyclerView创建此布局?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用这种类型的布局创建一个回收站视图.这些项目是字符串,可以以不同的大小出现,我不知道每行有多少个项目.我可以使用StaggeredGridLayoutManager来做到这一点吗? 图片只是一个伪造的例子,每行中可以有更多项目

I'm trying to create a recycler view with this type of layout. The items are strings and can apear with diferent sizes, i dont know how much items there will be in each row. Can I do this with a StaggeredGridLayoutManager? The image is just a fake example, there can be more items in each row

推荐答案

您可能想查看开源 FlexboxLayoutManager ,它是RecyclerView的布局管理器.

You might wanna check out the open-source FlexboxLayout, developed by Google, especially FlexboxLayoutManager which is a layout manager for a RecyclerView.

要使用正确的配置创建布局管理器,只需执行以下操作:

To create the layout manager with the right config, just do this:

FlexboxLayoutManager layoutManager = new FlexboxLayoutManager();
layoutManager.setFlexWrap(FlexWrap.WRAP);

有关更多信息,请查看Android开发者博客的帖子.

For more information, check out the Android Developers Blog's post.

这篇关于如何使用RecyclerView创建此布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆