在Recyclerview中使布局灵活

时间:2017-06-12 09:40:56

标签: android layout

如何实现下图中显示的此布局如果我的包含是直接从Web服务加载,请建议我如何在运行时进行布局。

Inshort App Screenshot

1 个答案:

答案 0 :(得分:1)

您可以使用FlexboxLayoutManager,这是片段

FlexboxLayoutManager layoutManager = new FlexboxLayoutManager();
layoutManager.setFlexWrap(FlexWrap.WRAP);
layoutManager.setFlexDirection(FlexDirection.ROW);
recyclerView.setLayoutManager(layoutManager);

在Gradle文件中,您必须编译此依赖项

compile 'com.google.android:flexbox:0.3.0-alpha3'

您可以查看此链接here