How to set RecyclerView layoutManager from XML?
<android.support.v7.widget.RecyclerView
app:layoutManager="???"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
How to set RecyclerView layoutManager from XML?
<android.support.v7.widget.RecyclerView
app:layoutManager="???"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
As you can check in the doc:
With androidx you can use:
if you want use it with
LinearLayoutManager
that equivalent to
And I came here looking for
androidx
version though it was pretty easy to figure out, here it isLinearLayoutManager:
Example:
GridLayoutManager:
Example:
As you can see in examples above you can control the orientation from within
xml
usingand
And to set the number of columns for GridLayoutManager using
The most common ones that I use are:
And:
It's recommended to set
listitem
, so that you'd see how it could look in the preview of the layout editor.If you want to have the order reversed though, I think you have to do it in code instead, and use "tools" in XML if you really want to see something...