【发布时间】:2016-06-11 07:47:45
【问题描述】:
如何从 XML 中设置RecyclerView layoutManager?
<android.support.v7.widget.RecyclerView
app:layoutManager="???"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
【问题讨论】:
-
@dieter_h 你能用 GridLayoutManager 的例子来回答吗?
-
您可以使用
app:layoutManager="android.support.v7.widget.GridLayoutManager"。将使用具有四个参数的构造函数(Context、AttributeSet、int、int)。根据文档,这是通过 RecyclerView 属性 layoutManager 在 XML 中设置布局管理器时使用的 构造函数。如果 XML 中未指定 spanCount,则默认为单列
标签: android xml android-recyclerview androidx