Getting started¶
Add the following dependency to your app's build.gradle
:
implementation "com.rubensousa.dpadrecyclerview:dpadrecyclerview:1.4.0"
// Recommended: To use Compose together with DpadRecyclerView
implementation "com.rubensousa.dpadrecyclerview:dpadrecyclerview-compose:1.4.0"
// Optional: Espresso test helpers for your instrumented tests:
androidTestImplementation "com.rubensousa.dpadrecyclerview:dpadrecyclerview-testing:1.4.0"
Basic setup¶
Since DpadRecyclerView
is a custom view that extends from RecyclerView
, you just need to add it to your XML layout as any other view:
Warning
Don't set a LayoutManager
because DpadRecyclerView
already assigns one internally.
Follow the official RecyclerView guides to render Views on the screen or use any RecyclerView library as you would for mobile apps.
You can also render Composables inside using the dpadrecyclerview-compose
library.
Observe selection changes¶
You can observe selection changes using the following:
Observe focus changes¶
To react to focus changes, use this:
How to use with Compose¶
Check this page to see more some examples with Compose
More customizations¶
Check the following recipes:
- Layout: for defining the type of layout (linear or grid) or to enable infinite carousels
- Spacing: add spacing between items
- Alignment: align items to different regions of the screen
- Focus: configure how focus is handled
- Scrolling: configure the scrolling speed
Sample¶
The sample on Github contains a complete example of how to use this library.