How to create this layout with a RecyclerView?

微笑、不失礼 提交于 2019-12-08 09:38:33

问题


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


回答1:


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);

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



来源:https://stackoverflow.com/questions/42602491/how-to-create-this-layout-with-a-recyclerview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!