首页 > 解决方案 > 在 RecyclerView 中设置逻辑填充数据

问题描述

我有 Recycler View 来显示我的网格。我的数据是int[] list = {1, 2, 3, 4, 5, 6, 7}; 并且我使用代码

mRv.setLayoutManager(new GridLayoutManager(mRvIcon.getContext(), 5, GridLayoutManager.VERTICAL, false));
mRv.setAdapter(myAdapter);

我有结果:

在此处输入图像描述

但我想填充数据相同

在此处输入图像描述

我该怎么做?

标签: android

解决方案


尝试像这样添加布局管理器

new GridLayoutManager(this, 5, GridLayoutManager.HORIZONTAL, false)

推荐阅读