Layout Recipes¶
Rows¶
A Row is simply a DpadRecyclerView
with RecyclerView.HORIZONTAL
as its orientation.
Do the following either in XML or Kotlin:
Note
To center views vertically inside a horizontal DpadRecyclerView
,
you can use the gravity
attribute like so:
Columns¶
A Column is simply a DpadRecyclerView
with RecyclerView.VERTICAL
as its orientation.
Do the following either in XML or Kotlin:
Grids¶
The API is similar to the one of GridLayoutManager
from androidx.recyclerview:
Different span sizes¶
To customise the size of each span, use DpadSpanSizeLookup
.
This example would create a full size header for the item at the first position:
Looping adapter contents¶
You can enable infinite scrolling by using setLoopDirection
to loop the adapter contents:
Note
Looping is only supported when there's enough items to fill the viewport
Extra layout space¶
DpadRecyclerView
won't layout any extra space by default, however,
you might want to create extra views in case you're aligning items to an edge.
The example below would create half a page of extra items at the start of the layout: