DpadRecyclerView
A RecyclerView that scrolls to items on DPAD key events.
Items are aligned based on the following configurations:
ParentAlignment aligns items in relation to this RecyclerView's dimensions
ChildAlignment aligns items in relation to their View's dimensions
Individual sub position configurations returned by DpadViewHolder.getSubPositionAlignments
This DpadRecyclerView will only scroll automatically when it has focus and receives DPAD key events. To scroll manually to any given item, check setSelectedPosition, setSelectedPositionSmooth and other related methods.
When using wrap_content for the main scrolling direction, DpadRecyclerView will still measure itself to match its parent's size, but will layout all items at once without any recycling.
Constructors
Types
Listener for intercepting key dispatch events.
Listener for receiving notifications of a completed layout pass by the LayoutManager of this RecyclerView
Listener for intercepting generic motion dispatch events.
Listener for intercepting touch dispatch events
Listener for intercepting unhandled key events.
Defines behavior of duration and interpolator for smoothScrollBy.
Functions
Registers a callback to be invoked when an item of this DpadRecyclerView has been laid out.
Registers a callback to be invoked when this RecyclerView loses focus
Registers a callback to be invoked when this RecyclerView completes a layout pass.
Registers a callback to be invoked when an item has been focused
Registers a callback to be invoked when an item has been selected
Clears all listeners added by addOnChildLaidOutListener
Clears all existing listeners added by addOnFocusLostListener
Clears all listeners added by addOnLayoutCompletedListener
Clears all existing listeners added by addOnViewFocusedListener
Clears all existing listeners added by addOnViewHolderSelectedListener
Enables fading out the max edge to transparent.
Enables fading out the min edge to transparent.
See setSpanCount
See: setLayoutEnabled
Returns if views are laid out from the opposite direction of the layout.
See setScrollEnabled.
Removes a listener added by addOnFocusLostListener
Removes a listener added by addOnLayoutCompletedListener
Removes a listener added by addOnViewFocusedListener
Removes a listener added by addOnViewHolderSelectedListener
Set a custom alignment configuration for each ViewHolder. Check AlignmentLookup. This is only supported in linear layouts
Updates both parent and child alignments
Updates the child alignment configuration for child views of this RecyclerView
Sets the strategy for calculating extra layout space.
Changes how RecyclerView will find the next focusable view. Check FocusableDirection for all supported directions. Default is FocusableDirection.STANDARD
Enables or disables the default rule of drawing the selected view after all other views. Default is true
Sets whether focus can move out from the front and/or back of the RecyclerView.
Sets whether focus can move out from the opposite front and/or back of the RecyclerView
Disables or enables focus search.
Disables or enables focus search while RecyclerView is animating item changes. See RecyclerView.isAnimating.
Sets the gravity used for child view positioning. Defaults to Gravity.TOP for horizontal orientation and Gravity.START for vertical orientation.
Controls the return value of View.hasOverlappingRendering.
Sets the number of items to prefetch in RecyclerView.LayoutManager.collectInitialPrefetchPositions, which defines how many inner items should be prefetched when this RecyclerView is nested inside another RecyclerView.
Sets the spacing between the min end and the first item, and the last item and the min edge. This is equivalent to calling both setItemMinEdgeSpacing and setItemMaxEdgeSpacing with the same value.
Set the spacing between the max edge and the last item
Set the spacing between the min edge and the first item
Set the spacing between different items
Allows disabling the layout of children. All children are removed if layout is disabled
By default, DpadRecyclerView does not skip layout requests during scrolling, but you might want to do this because of the following:
Updates the loop direction used by this DpadRecyclerView. By default, the layout does not loop around the items
Sets the length of the fading effect applied to the max edge in pixels
Sets the length of the fading effect applied to the min edge in pixels
Sets the length of the fading effect applied to the min edge in pixels
Sets the start position of the fading effect applied to the min edge in pixels. Default is 0, which means that the fading effect starts from the min edge (left or top)
Registers a callback to be invoked when an item of this DpadRecyclerView has been laid out.
Set a listener that intercepts key events received in dispatchKeyEvent
Sets the generic motion intercept listener.
Sets a listener for intercepting touch events
Set a listener that intercepts unhandled key events from dispatchKeyEvent
Updates the orientation of the PivotLayoutManager used by this RecyclerView
Updates the parent alignment configuration for child views of this RecyclerView
Set whether the LayoutManager of this RecyclerView will recycle its children when this RecyclerView is detached from the window.
Used to reverse item traversal and layout order. This behaves similar to the layout change for RTL views. When set to true, first item is laid out at the end of the UI, second item is laid out before it etc.
Enables or disables scrolling. When this is disabled, DpadRecyclerView can still change focus on DPAD events unless setFocusSearchDisabled is also set.
Changes the selected item immediately without any scroll animation.
Performs a task on a ViewHolder at a given position after scrolling to it.
Changes the selected item and runs an animation to scroll to the target position.
Performs a task on a ViewHolder at a given position after scrolling to it.
Changes the sub selected view immediately without any scroll animation.
Changes the main selection and sub selected view immediately without any scroll animation.
Performs a task on a ViewHolder at a given position and sub position after scrolling to it.
Changes the sub selected view and runs and animation to scroll to it.
Performs a task on a ViewHolder at a given position and sub position after scrolling to it.
Enable or disable smooth scrolling to new focused position. By default, this is set to true. When set to false, RecyclerView will scroll immediately to the focused view without any animation.
Set a custom behavior for smoothScrollBy
Whenever the user triggers a focus change via a key event, DpadRecyclerView will check if it already has max number of pending alignment changes before dispatching focus to the next view.
When the user holds down a key, a lot of key events will be generated by the system. These events are generated a lot faster than this DpadRecyclerView can scroll, so these events need to be cached until the user stops pressing the key.
Set how slow the smooth scroller should run. Example:
Updates the number of spans of the PivotLayoutManager used by this RecyclerView.
Updates the DpadSpanSizeLookup used by the layout manager of this RecyclerView.