【发布时间】:2016-11-25 17:22:35
【问题描述】:
我将GridLayoutManager 用于RecyclerView 和GridLayoutManager.HORIZONTAL 方向。 SpanCount 对我来说不能正常工作,因为它取决于布局方向,但我知道我需要多少列和行。我该怎么办?
从文档到setSpanCount(int spanCount):
/**
* Sets the number of spans to be laid out.
* <p>
* If {@link #getOrientation()} is {@link #VERTICAL}, this is the number of columns.
* If {@link #getOrientation()} is {@link #HORIZONTAL}, this is the number of rows.
*
* @param spanCount The total number of spans in the grid
* @see #getSpanCount()
*/
示例:我的RecyclerView 尺寸是match_parent,如果我有 9 个项目,我有 3x3 网格,如果我有 5 个项目,我有 3x2 网格,但我想要 2x3。
附:我不想设置GridLayoutManager.VERTICAL 布局方向。
屏幕截图不正确,我想要 2x3 网格。
【问题讨论】:
标签: android android-recyclerview gridlayoutmanager