Migrating from Leanback¶
Interopability¶
DpadRecyclerView is also compatible with Leanback and can be used together in the same view hierarchy.
You can combine DpadRecyclerView with BaseGridView as follows:
-
DpadRecyclerViewas the parent RecyclerView andBaseGridViewfor the nested lists -
BaseGridViewas the parent RecyclerView andDpadRecyclerViewfor the nested lists
Themes¶
DpadRecyclerView does not require any theme like Theme.Leanback, so feel free to use any.
VerticalGridView and HorizontalGridView¶
Instead of using VerticalGridView or HorizontalGridView, use DpadRecyclerView and set the orientation either programmatically
with setOrientation or with plain XML:
Window Alignment¶
The window alignment APIs from BaseGridView can now be found in the ParentAlignment class.
Edge alignment mapping:
| BaseGridView | DpadRecyclerView |
|---|---|
BaseGridView.WINDOW_ALIGN_NO_EDGE |
ParentAlignment.Edge.NONE |
BaseGridView.WINDOW_ALIGN_LOW_EDGE |
ParentAlignment.Edge.MIN |
BaseGridView.WINDOW_ALIGN_MAX_EDGE |
ParentAlignment.Edge.MAX |
BaseGridView.WINDOW_ALIGN_BOTH_EDGE |
ParentAlignment.Edge.MIN_MAX |
Item Alignment¶
The child alignment APIs from BaseGridView can now be found in the ChildAlignment class.
Selection changes¶
ItemAlignmentFacet or FacetProviderAdapter¶
This was typically used for configuring sub position alignment. Check this page for more information about sub position alignment.
If you were using FacetProviderAdapter for anything else, just write your own logic in the RecyclerView.Adapter and expose those events to the ViewHolders directly
Item spacing¶
DpadRecyclerView ships with DpadLinearSpacingDecoration and DpadGridSpacingDecoration to achieve this, together with setItemSpacing and similar APIs.
Please check the examples in the recipes at Spacing.
Fading edges¶
Support for fading edges is enabled with the default XML attribute fadingEdgeLength.
Alternatively, you can customise the fading edge with the following methods:
setMinEdgeFadingLengthsetMinEdgeFadingOffsetsetMaxEdgeFadingLengthsetMaxEdgeFadingOffsetsetFadingEdgeLength
Presenters¶
These will still work out of the box with DpadRecyclerView since they're just a wrapper over RecyclerView.Adapter,
but feel free to use any other RecyclerView framework in case you want to get rid completely of the Leanback library.