如何对齐回收者视图项目

时间:2019-02-26 05:25:12

标签: android android-recyclerview

如何对齐RecyclerView项目。我正在使用ChipsLayoutManager,以便可以并排获取正在运行的项目,但它留有很多空间,我希望下一个项目在第一个末端继续。

代码如下:

ChipsLayoutManager chipsLayoutManager = ChipsLayoutManager.newBuilder(Quran_e_Kareem.this)
                //a layoutOrientation of layout manager, could be VERTICAL OR HORIZONTAL. HORIZONTAL by default
                .setOrientation(ChipsLayoutManager.HORIZONTAL)
                // row strategy for views in completed row, could be STRATEGY_DEFAULT, STRATEGY_FILL_VIEW,
                //STRATEGY_FILL_SPACE or STRATEGY_CENTER
                .setRowStrategy(ChipsLayoutManager.STRATEGY_DEFAULT)
                // whether strategy is applied to last row. FALSE by default
                .build();
        listView.setLayoutManager(chipsLayoutManager);

I am getting output like this

But i want to get this way

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

这将为您提供帮助

   ChipsLayoutManager chipsLayoutManager = ChipsLayoutManager.newBuilder(this)
                        .setOrientation(ChipsLayoutManager.HORIZONTAL)
                        .build();