android - 将水平 RecyclerView 项目与边框对齐

标签 android android-layout android-recyclerview android-view

我希望我的 RecyclerView 项目与屏幕边框对齐,
android:layout_width="match_parent" 不工作,它给了我这个结果:

enter image description here

虽然这是我想要实现的目标:

enter image description here

如有任何帮助,我们将不胜感激。

最佳答案

recyclerView.setLayoutManager(new GridLayoutManager(this, numberOfColumns)); 在这里,numberOfColumns 值将是 2,如果您想以网格方式一次等距显示给项目。

关于android - 将水平 RecyclerView 项目与边框对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58820710/

相关文章:

java - 使用 Android 将图像读取为字节数组:skImageDecoder::Factory 返回 null

android - RecyclerView View 中的 EditText 在键盘打开时分离

android - 在自动化的Android构建中找不到插件gradle错误

android - 为什么我需要将配置文件添加到我的项目中才能正确设置 GCM?

Android 如何让 scrollView 在点击 editText 时自动滚动到底部?

android - 所有屏幕尺寸的资源文件夹名称

android - Material -1.5.0-alpha03\res\values-v31\values-v31.xml :3:5-94: AAPT: error: resource android:color/system_neutral1_1000 not found

java - 如何用下一页填充标题和网格布局 "10 items"

Android Toast 不显示

android-layout - Android XML : Percentage Height and width to create unique layout