Ich habe GridLayoutManager
für RecyclerView
mit GridLayoutManager.HORIZONTAL
Orientierung verwendet. SpanCount funktioniert nicht korrekt für mich, weil es von der Layoutausrichtung abhängt, aber ich weiß, wie viel Spalten und Zeilen ich brauche. Wie kann ich es tun?GridLayoutManager Spalten- und Zeilenanzahl setzen
Von Dokumentation zu 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()
*/
Beispiel: Mein RecyclerView
Größe ist match_parent
, wenn ich 9 Einzelteile haben, ich habe Gitter 3x3, wenn ich 5 Einzelteile haben, i Gitter 3x2 haben, aber ich 2x3 wollen .
P.S. Ich möchte GridLayoutManager.VERTICAL
Layoutausrichtung nicht festlegen.
In Screenshot ist nicht korrekt, ich möchte Grid 2x3.
es lässt Abstand zwischen den Zeilen, wenn es 4-6 Elemente sagt – ViVekH