BaseGridView
public abstract class BaseGridView extends RecyclerView
| java.lang.Object | ||||
| ↳ | android.view.View | |||
| ↳ | android.view.ViewGroup | |||
| ↳ | androidx.recyclerview.widget.RecyclerView | |||
| ↳ | androidx.leanback.widget.BaseGridView |
HorizontalGridView |
A |
VerticalGridView |
A |
An abstract base class for vertically and horizontally scrolling lists. The items come from the RecyclerView.Adapter associated with this view. Do not directly use this class, use VerticalGridView and HorizontalGridView. The class is not intended to be subclassed other than VerticalGridView and HorizontalGridView.
Summary
Nested types |
|---|
public interface BaseGridView.OnKeyInterceptListenerListener for intercepting key dispatch events. |
public interface BaseGridView.OnLayoutCompletedListenerInterface for receiving notification when BaseGridView has completed a full layout calculation. |
public interface BaseGridView.OnMotionInterceptListenerListener for intercepting generic motion dispatch events. |
public interface BaseGridView.OnTouchInterceptListenerListener for intercepting touch dispatch events. |
public interface BaseGridView.OnUnhandledKeyListenerListener for intercepting unhandled key events. |
public interface BaseGridView.SmoothScrollByBehaviorDefines behavior of duration and interpolator for smoothScrollBy(). |
Constants |
|
|---|---|
static final float |
Value indicates that percent is not used. |
static final int |
SAVE_ALL_CHILD = 3Save on screen views plus save off screen child views without any limitation. |
static final int |
Save on screen views plus save off screen child views states up to |
static final int |
SAVE_NO_CHILD = 0Dont save states of any child views. |
static final int |
Only save on screen child views, the states are lost when they become off screen. |
static final int |
The first item and last item are aligned with the two edges of the viewport. |
static final int |
The last item is aligned with the high edge of the viewport when navigating to the end of list. |
static final int |
The first item is aligned with the low edge of the viewport. |
static final int |
The focused item always stays in a key line location. |
static final float |
Value indicates that percent is not used. |
Public methods |
|
|---|---|
void |
Registers a callback to be invoked when an item in BaseGridView has been selected. |
final void |
Registers a callback to be invoked when the BaseGridView completes a full layout calculation. |
void |
Undo animateOut() and slide in child views. |
void |
Temporarily slide out child views to bottom (for VerticalGridView) or end (for HorizontalGridView). |
boolean |
dispatchKeyEvent(@NonNull KeyEvent event) |
boolean |
dispatchTouchEvent(@NonNull MotionEvent event) |
@Nullable View |
focusSearch(int direction) |
int |
getChildDrawingOrder(int childCount, int i) |
int |
This method is deprecated. |
int |
Returns the horizontal spacing in pixels between two child items. |
int |
Gets the number of items to prefetch in |
int |
Returns number of pixels to the end of low edge. |
float |
Returns the offset percent for item alignment in addition to |
int |
Returns the id of the view to align with, or |
@Nullable BaseGridView.OnUnhandledKeyListener |
Returns the unhandled key listener. |
final int |
Returns the limit used when when |
final int |
Returns the policy for saving children. |
int |
Returns the adapter position of selected item. |
@Nullable BaseGridView.SmoothScrollByBehavior |
Returns custom behavior for smoothScrollBy(). |
final int |
When holding DPAD, DPAD events are generated faster than the grid view can scroll. |
final float |
|
int |
This method is deprecated. |
int |
Returns the vertical spacing in pixels between two child items. |
void |
getViewSelectedOffsets(@NonNull View view, @NonNull int[] offsets)Returns the x/y offsets to final position from current position if the view is selected. |
int |
Returns the method for focused item alignment in the view. |
int |
Returns the offset in pixels for window alignment key line. |
float |
Returns the offset percent for window alignment key line in addition to |
boolean |
|
boolean |
hasPreviousViewInSameRow(int position)Returns true if the view at the given position has a same row sibling in front of it. |
boolean |
Returns true if an animation will run when a child changes size or when adding or removing a child. |
boolean |
Returns true if draws selected child at last, false otherwise. |
final boolean |
Returns true if focus search is disabled. |
boolean |
Returns true if applies padding to item alignment when |
boolean |
Returns true if scrolling is enabled, false otherwise. |
boolean |
Returns whether prefer key line over high edge when |
boolean |
Returns whether prefer key line over low edge when |
boolean |
onRequestFocusInDescendants( |
void |
onRtlPropertiesChanged(int layoutDirection)Notify layout manager that layout directionality has been updated |
void |
Remove the callback invoked when an item in BaseGridView has been selected. |
final void |
Removes a callback to be invoked when the BaseGridView completes a full layout calculation. |
void |
removeView(@NonNull View view) |
void |
removeViewAt(int index) |
void |
scrollToPosition(int position)Convenience method to scroll to a certain position. |
void |
setAnimateChildLayout(boolean animateChildLayout)Sets whether ItemAnimator should run when a child changes size or when adding or removing a child. |
void |
setChildrenVisibility(int visibility)Changes and overrides children's visibility. |
void |
setFocusDrawingOrderEnabled(boolean enabled)Enables or disables the default "focus draw at last" order rule. |
final void |
setFocusSearchDisabled(boolean disabled)Disables or enables focus search. |
void |
setGravity(int gravity)Sets the gravity used for child view positioning. |
void |
setHasOverlappingRendering(boolean hasOverlapping) |
void |
This method is deprecated. |
void |
setHorizontalSpacing(int spacing)Sets the horizontal spacing in pixels between two child items. |
void |
setInitialPrefetchItemCount(int itemCount)Sets the number of items to prefetch in |
void |
setItemAlignmentOffset(int offset)Sets number of pixels to the end of low edge. |
void |
setItemAlignmentOffsetPercent(float offsetPercent)Sets the offset percent for item alignment in addition to |
void |
setItemAlignmentOffsetWithPadding(boolean withPadding)Sets whether applies padding to item alignment when |
void |
setItemAlignmentViewId(int viewId)Sets the id of the view to align with. |
void |
This method is deprecated. use |
void |
setItemSpacing(int spacing)Sets the vertical and horizontal spacing in pixels between two child items. |
void |
setLayoutEnabled(boolean layoutEnabled)Enables or disables layout. |
void |
Set the |
void |
Registers a callback to be invoked when an item in BaseGridView has been laid out. |
void |
Registers a callback to be invoked when an item in BaseGridView has been selected. |
void |
Registers a callback to be invoked when an item in BaseGridView has been selected. |
void |
Sets the key intercept listener. |
void |
Sets the generic motion intercept listener. |
void |
Sets the touch intercept listener. |
void |
Sets the unhandled key listener. |
void |
setPruneChild(boolean pruneChild)Enables or disables pruning of children. |
final void |
setSaveChildrenLimitNumber(int limitNumber)Sets the limit number when |
final void |
setSaveChildrenPolicy(int savePolicy)Sets the policy for saving children. |
void |
setScrollEnabled(boolean scrollEnabled)Enables or disables scrolling. |
void |
setSelectedPosition(int position)Changes the selected item immediately without animation. |
void |
setSelectedPosition(int position, int scrollExtra)Changes the selected item immediately without animation, scrollExtra is applied in primary scroll direction. |
void |
setSelectedPosition(int position, @Nullable ViewHolderTask task)Perform a task on ViewHolder at given position after scroll to it. |
void |
setSelectedPositionSmooth(int position)Changes the selected item and run an animation to scroll to the target position. |
void |
setSelectedPositionSmooth(int position, @Nullable ViewHolderTask task)Perform a task on ViewHolder at given position after smooth scrolling to it. |
final void |
Set custom behavior for smoothScrollBy(). |
final void |
setSmoothScrollMaxPendingMoves(int maxPendingMoves)When holding DPAD, DPAD events are generated faster than the grid view can scroll. |
final void |
setSmoothScrollSpeedFactor(float smoothScrollSpeedFactor)Set factor of how slow the smoothScroller should run. |
void |
This method is deprecated. |
void |
setVerticalSpacing(int spacing)Sets the vertical spacing in pixels between two child items. |
void |
setWindowAlignment(int windowAlignment)Sets the method for focused item alignment in the view. |
void |
setWindowAlignmentOffset(int offset)Sets the offset in pixels for window alignment key line. |
void |
setWindowAlignmentOffsetPercent(float offsetPercent)Sets the offset percent for window alignment key line in addition to |
void |
setWindowAlignmentPreferKeyLineOverHighEdge(Returns whether prefer key line over high edge when |
void |
setWindowAlignmentPreferKeyLineOverLowEdge(Sets whether prefer key line over low edge when |
void |
smoothScrollBy(int dx, int dy)Animate a scroll by the given amount of pixels along either axis. |
void |
smoothScrollBy(int dx, int dy, @Nullable Interpolator interpolator)Animate a scroll by the given amount of pixels along either axis. |
void |
smoothScrollToPosition(int position)Starts a smooth scroll to an adapter position. |
Protected methods |
|
|---|---|
boolean |
|
void |
onFocusChanged( |
Inherited Constants |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Inherited methods |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Constants
ITEM_ALIGN_OFFSET_PERCENT_DISABLED
public static final float ITEM_ALIGN_OFFSET_PERCENT_DISABLED = -1.0f
Value indicates that percent is not used.
SAVE_ALL_CHILD
public static final int SAVE_ALL_CHILD = 3
Save on screen views plus save off screen child views without any limitation. This might cause out of memory, only use it when you are dealing with limited data.
SAVE_LIMITED_CHILD
public static final int SAVE_LIMITED_CHILD = 2
Save on screen views plus save off screen child views states up to getSaveChildrenLimitNumber.
SAVE_NO_CHILD
public static final int SAVE_NO_CHILD = 0
Dont save states of any child views.
SAVE_ON_SCREEN_CHILD
public static final int SAVE_ON_SCREEN_CHILD = 1
Only save on screen child views, the states are lost when they become off screen.
WINDOW_ALIGN_BOTH_EDGE
public static final int WINDOW_ALIGN_BOTH_EDGE = 3
The first item and last item are aligned with the two edges of the viewport. When navigating in the middle of list, the focus maintains a key line location.
The key line location is calculated by "windowAlignOffset" and "windowAlignOffsetPercent"; if neither of these two is defined, the default value is 1/2 of the size.
WINDOW_ALIGN_HIGH_EDGE
public static final int WINDOW_ALIGN_HIGH_EDGE = 2
The last item is aligned with the high edge of the viewport when navigating to the end of list. When navigating away from the end, the focus item is aligned to a key line location.
For HorizontalGridView, high edge refers to getWidth() - getPaddingRight() when RTL is false or getPaddingLeft() when RTL is true. For VerticalGridView, high edge refers to getHeight() - getPaddingBottom().
The key line location is calculated by "windowAlignOffset" and "windowAlignOffsetPercent"; if neither of these two is defined, the default value is 1/2 of the size.
Note if there are very few items between high edge and key line, use setWindowAlignmentPreferKeyLineOverHighEdge to control whether you prefer to align the items to key line or high edge. Default is preferring key line.
WINDOW_ALIGN_LOW_EDGE
public static final int WINDOW_ALIGN_LOW_EDGE = 1
The first item is aligned with the low edge of the viewport. When navigating away from the first item, the focus item is aligned to a key line location.
For HorizontalGridView, low edge refers to getPaddingLeft() when RTL is false or getWidth() - getPaddingRight() when RTL is true. For VerticalGridView, low edge refers to getPaddingTop().
The key line location is calculated by "windowAlignOffset" and "windowAlignOffsetPercent"; if neither of these two is defined, the default value is 1/2 of the size.
Note if there are very few items between low edge and key line, use setWindowAlignmentPreferKeyLineOverLowEdge to control whether you prefer to align the items to key line or low edge. Default is preferring low edge.
WINDOW_ALIGN_NO_EDGE
public static final int WINDOW_ALIGN_NO_EDGE = 0
The focused item always stays in a key line location.
The key line location is calculated by "windowAlignOffset" and "windowAlignOffsetPercent"; if neither of these two is defined, the default value is 1/2 of the size.
WINDOW_ALIGN_OFFSET_PERCENT_DISABLED
public static final float WINDOW_ALIGN_OFFSET_PERCENT_DISABLED = -1.0f
Value indicates that percent is not used.
Public methods
addOnChildViewHolderSelectedListener
public void addOnChildViewHolderSelectedListener(
@NonNull OnChildViewHolderSelectedListener listener
)
Registers a callback to be invoked when an item in BaseGridView has been selected. Note that the listener may be invoked when there is a layout pending on the view, affording the listener an opportunity to adjust the upcoming layout based on the selection state.
| Parameters | |
|---|---|
@NonNull OnChildViewHolderSelectedListener listener |
The listener to be invoked. |
addOnLayoutCompletedListener
public final void addOnLayoutCompletedListener(
@NonNull BaseGridView.OnLayoutCompletedListener listener
)
Registers a callback to be invoked when the BaseGridView completes a full layout calculation.
| Parameters | |
|---|---|
@NonNull BaseGridView.OnLayoutCompletedListener listener |
The listener to be invoked. |
animateOut
public void animateOut()
Temporarily slide out child views to bottom (for VerticalGridView) or end (for HorizontalGridView). Layout and scrolling will be suppressed until animateIn is called.
public int getHorizontalMargin()Returns the spacing in pixels between two child items horizontally.
getHorizontalSpacing
public int getHorizontalSpacing()
Returns the horizontal spacing in pixels between two child items.
| Returns | |
|---|---|
int |
The Horizontal spacing in pixels between two child items. |
getInitialPrefetchItemCount
public int getInitialPrefetchItemCount()
Gets the number of items to prefetch in collectInitialPrefetchPositions, which defines how many inner items should be prefetched when this GridView is nested inside another RecyclerView.
| Returns | |
|---|---|
int |
number of items to prefetch. |
getItemAlignmentOffset
public int getItemAlignmentOffset()
Returns number of pixels to the end of low edge. Supports right to left layout direction. In left to right or vertical case, it's the offset added to left/top edge. In right to left case, it's the offset subtracted from right edge. Item alignment settings are ignored for the child if ItemAlignmentFacet is provided by RecyclerView.ViewHolder or FacetProviderAdapter.
| Returns | |
|---|---|
int |
The number of pixels to the end of low edge. |
getItemAlignmentOffsetPercent
public float getItemAlignmentOffsetPercent()
Returns the offset percent for item alignment in addition to getItemAlignmentOffset.
| Returns | |
|---|---|
float |
Percentage to offset. E.g., 40 means 40% of the width from the low edge, or |
getItemAlignmentViewId
public int getItemAlignmentViewId()
Returns the id of the view to align with, or NO_ID for the root itemView.
getOnUnhandledKeyListener
public @Nullable BaseGridView.OnUnhandledKeyListener getOnUnhandledKeyListener()
Returns the unhandled key listener.
| Returns | |
|---|---|
@Nullable BaseGridView.OnUnhandledKeyListener |
The unhandled key listener. |
getSaveChildrenLimitNumber
public final int getSaveChildrenLimitNumber()
Returns the limit used when when getSaveChildrenPolicy is SAVE_LIMITED_CHILD
getSaveChildrenPolicy
public final int getSaveChildrenPolicy()
Returns the policy for saving children.
| Returns | |
|---|---|
int |
policy, one of |
getSelectedPosition
public int getSelectedPosition()
Returns the adapter position of selected item.
| Returns | |
|---|---|
int |
The adapter position of selected item. |
getSmoothScrollByBehavior
public @Nullable BaseGridView.SmoothScrollByBehavior getSmoothScrollByBehavior()
Returns custom behavior for smoothScrollBy().
| Returns | |
|---|---|
@Nullable BaseGridView.SmoothScrollByBehavior |
Custom behavior for SmoothScrollBy(). Null for default behavior. |
getSmoothScrollMaxPendingMoves
public final int getSmoothScrollMaxPendingMoves()
When holding DPAD, DPAD events are generated faster than the grid view can scroll. The grid view counts unhandled DPAD events and complete the movement after user release DPAD. If the value is set too high, the scrolling will last very long after DPAD is released. If the value is set too low, it may miss many DPAD events. The default value is 10. If app increases setSmoothScrollSpeedFactor, it may need decrease the max pending DPAD events to avoid scrolling too long after DPAD release.
| Returns | |
|---|---|
int |
Maximum number of pending DPAD events to be remembered when smooth scroll cannot catch up speed of DPAD events being sent. |
getSmoothScrollSpeedFactor
public final float getSmoothScrollSpeedFactor()
| Returns | |
|---|---|
float |
Factor of how slow the smoothScroller runs. Default value is 1f. |
getVerticalSpacing
public int getVerticalSpacing()
Returns the vertical spacing in pixels between two child items.
| Returns | |
|---|---|
int |
The vertical spacing in pixels between two child items. |
getViewSelectedOffsets
public void getViewSelectedOffsets(@NonNull View view, @NonNull int[] offsets)
Returns the x/y offsets to final position from current position if the view is selected.
getWindowAlignment
public int getWindowAlignment()
Returns the method for focused item alignment in the view.
getWindowAlignmentOffset
public int getWindowAlignmentOffset()
Returns the offset in pixels for window alignment key line.
| Returns | |
|---|---|
int |
The number of pixels to offset. If the offset is positive, it is distance from low edge (see |
getWindowAlignmentOffsetPercent
public float getWindowAlignmentOffsetPercent()
Returns the offset percent for window alignment key line in addition to getWindowAlignmentOffset.
| Returns | |
|---|---|
float |
Percentage to offset. E.g., 40 means 40% of the width from the low edge, or |
hasPreviousViewInSameRow
public boolean hasPreviousViewInSameRow(int position)
Returns true if the view at the given position has a same row sibling in front of it. This will return true if first item view is not created.
| Parameters | |
|---|---|
int position |
Position in adapter. |
| Returns | |
|---|---|
boolean |
True if the view at the given position has a same row sibling in front of it. |
isChildLayoutAnimated
public boolean isChildLayoutAnimated()
Returns true if an animation will run when a child changes size or when adding or removing a child.
| Returns | |
|---|---|
boolean |
True if ItemAnimator is enabled, false otherwise. |
isFocusDrawingOrderEnabled
public boolean isFocusDrawingOrderEnabled()
Returns true if draws selected child at last, false otherwise. Default is enabled.
| Returns | |
|---|---|
boolean |
True if draws selected child at last, false otherwise. |
isFocusSearchDisabled
public final boolean isFocusSearchDisabled()
Returns true if focus search is disabled.
| Returns | |
|---|---|
boolean |
True if focus search is disabled. |
isItemAlignmentOffsetWithPadding
public boolean isItemAlignmentOffsetWithPadding()
Returns true if applies padding to item alignment when getItemAlignmentOffsetPercent is 0 or 100; returns false otherwise.
When true: Applies start/top padding when getItemAlignmentOffsetPercent is 0. Applies end/bottom padding when getItemAlignmentOffsetPercent is 100. Does not apply padding if getItemAlignmentOffsetPercent is neither 0 nor 100.
When false: does not apply padding
isScrollEnabled
public boolean isScrollEnabled()
Returns true if scrolling is enabled, false otherwise.
| Returns | |
|---|---|
boolean |
True if scrolling is enabled, false otherwise. |
isWindowAlignmentPreferKeyLineOverHighEdge
public boolean isWindowAlignmentPreferKeyLineOverHighEdge()
Returns whether prefer key line over high edge when WINDOW_ALIGN_HIGH_EDGE is used. When true, if there are very few items between high edge and key line, align items to key line instead of align items to high edge. Default value is true (aka prefer align to key line).
| Returns | |
|---|---|
boolean |
True to prefer key line over high edge, false otherwise. |
isWindowAlignmentPreferKeyLineOverLowEdge
public boolean isWindowAlignmentPreferKeyLineOverLowEdge()
Returns whether prefer key line over low edge when WINDOW_ALIGN_LOW_EDGE is used. When true, if there are very few items between low edge and key line, align items to key line instead of align items to low edge. Default value is false (aka prefer align to low edge).
| Returns | |
|---|---|
boolean |
True to prefer key line over low edge, false otherwise. |
onRequestFocusInDescendants
public boolean onRequestFocusInDescendants(
int direction,
@Nullable Rect previouslyFocusedRect
)
onRtlPropertiesChanged
public void onRtlPropertiesChanged(int layoutDirection)
Notify layout manager that layout directionality has been updated
removeOnChildViewHolderSelectedListener
public void removeOnChildViewHolderSelectedListener(
@NonNull OnChildViewHolderSelectedListener listener
)
Remove the callback invoked when an item in BaseGridView has been selected.
| Parameters | |
|---|---|
@NonNull OnChildViewHolderSelectedListener listener |
The listener to be removed. |
removeOnLayoutCompletedListener
public final void removeOnLayoutCompletedListener(
@NonNull BaseGridView.OnLayoutCompletedListener listener
)
Removes a callback to be invoked when the BaseGridView completes a full layout calculation.
| Parameters | |
|---|---|
@NonNull BaseGridView.OnLayoutCompletedListener listener |
The listener to be invoked. |
scrollToPosition
public void scrollToPosition(int position)
Convenience method to scroll to a certain position. RecyclerView does not implement scrolling logic, rather forwards the call to scrollToPosition
| Parameters | |
|---|---|
int position |
Scroll to this adapter position |
| See also | |
|---|---|
scrollToPosition |
setAnimateChildLayout
public void setAnimateChildLayout(boolean animateChildLayout)
Sets whether ItemAnimator should run when a child changes size or when adding or removing a child.
| Parameters | |
|---|---|
boolean animateChildLayout |
True to enable ItemAnimator, false to disable. |
setChildrenVisibility
public void setChildrenVisibility(int visibility)
Changes and overrides children's visibility.
| Parameters | |
|---|---|
int visibility |
See |
setFocusDrawingOrderEnabled
public void setFocusDrawingOrderEnabled(boolean enabled)
Enables or disables the default "focus draw at last" order rule. Default is enabled.
| Parameters | |
|---|---|
boolean enabled |
True to draw the selected child at last, false otherwise. |
setFocusSearchDisabled
public final void setFocusSearchDisabled(boolean disabled)
Disables or enables focus search.
| Parameters | |
|---|---|
boolean disabled |
True to disable focus search, false to enable. |
setGravity
public void setGravity(int gravity)
Sets the gravity used for child view positioning. Defaults to GRAVITY_TOP|GRAVITY_START.
| Parameters | |
|---|---|
int gravity |
setHasOverlappingRendering
public void setHasOverlappingRendering(boolean hasOverlapping)
public void setHorizontalMargin(int margin)Sets the spacing in pixels between two child items horizontally.
setHorizontalSpacing
public void setHorizontalSpacing(int spacing)
Sets the horizontal spacing in pixels between two child items.
| Parameters | |
|---|---|
int spacing |
Horizontal spacing in pixels between two child items. |
setInitialPrefetchItemCount
public void setInitialPrefetchItemCount(int itemCount)
Sets the number of items to prefetch in collectInitialPrefetchPositions, which defines how many inner items should be prefetched when this GridView is nested inside another RecyclerView.
Set this value to the number of items this inner GridView will display when it is first scrolled into the viewport. RecyclerView will attempt to prefetch that number of items so they are ready, avoiding jank as the inner GridView is scrolled into the viewport.
For example, take a VerticalGridView of scrolling HorizontalGridViews. The rows always have 6 items visible in them (or 7 if not aligned). Passing 6 to this method for each inner GridView will enable RecyclerView's prefetching feature to do create/bind work for 6 views within a row early, before it is scrolled on screen, instead of just the default 4.
Calling this method does nothing unless the LayoutManager is in a RecyclerView nested in another RecyclerView.
Note: Setting this value to be larger than the number of views that will be visible in this view can incur unnecessary bind work, and an increase to the number of Views created and in active use.
| Parameters | |
|---|---|
int itemCount |
Number of items to prefetch |
setItemAlignmentOffset
public void setItemAlignmentOffset(int offset)
Sets number of pixels to the end of low edge. Supports right to left layout direction. Item alignment settings are ignored for the child if ItemAlignmentFacet is provided by RecyclerView.ViewHolder or FacetProviderAdapter.
| Parameters | |
|---|---|
int offset |
In left to right or vertical case, it's the offset added to left/top edge. In right to left case, it's the offset subtracted from right edge. |
setItemAlignmentOffsetPercent
public void setItemAlignmentOffsetPercent(float offsetPercent)
Sets the offset percent for item alignment in addition to getItemAlignmentOffset. Item alignment settings are ignored for the child if ItemAlignmentFacet is provided by RecyclerView.ViewHolder or FacetProviderAdapter.
| Parameters | |
|---|---|
float offsetPercent |
Percentage to offset. E.g., 40 means 40% of the width from the low edge. Use |
setItemAlignmentOffsetWithPadding
public void setItemAlignmentOffsetWithPadding(boolean withPadding)
Sets whether applies padding to item alignment when getItemAlignmentOffsetPercent is 0 or 100.
When true: Applies start/top padding if getItemAlignmentOffsetPercent is 0. Applies end/bottom padding if getItemAlignmentOffsetPercent is 100. Does not apply padding if getItemAlignmentOffsetPercent is neither 0 nor 100.
When false: does not apply padding
setItemAlignmentViewId
public void setItemAlignmentViewId(int viewId)
Sets the id of the view to align with. Use NO_ID (default) for the root itemView. Item alignment settings on BaseGridView are if ItemAlignmentFacet is provided by RecyclerView.ViewHolder or FacetProviderAdapter.
setItemSpacing
public void setItemSpacing(int spacing)
Sets the vertical and horizontal spacing in pixels between two child items.
| Parameters | |
|---|---|
int spacing |
Vertical and horizontal spacing in pixels between two child items. |
setLayoutEnabled
public void setLayoutEnabled(boolean layoutEnabled)
Enables or disables layout. All children will be removed when layout is disabled.
| Parameters | |
|---|---|
boolean layoutEnabled |
True to enable layout, false otherwise. |
setLayoutManager
public void setLayoutManager(@Nullable RecyclerView.LayoutManager layout)
Set the LayoutManager that this RecyclerView will use.
In contrast to other adapter-backed views such as android.widget.ListView or android.widget.GridView, RecyclerView allows client code to provide custom layout arrangements for child views. These arrangements are controlled by the LayoutManager. A LayoutManager must be provided for RecyclerView to function.
Several default strategies are provided for common uses such as lists and grids.
| Parameters | |
|---|---|
@Nullable RecyclerView.LayoutManager layout |
LayoutManager to use |
setOnChildLaidOutListener
public void setOnChildLaidOutListener(@Nullable OnChildLaidOutListener listener)
Registers a callback to be invoked when an item in BaseGridView has been laid out.
| Parameters | |
|---|---|
@Nullable OnChildLaidOutListener listener |
The listener to be invoked. |
setOnChildSelectedListener
public void setOnChildSelectedListener(@Nullable OnChildSelectedListener listener)
Registers a callback to be invoked when an item in BaseGridView has been selected. Note that the listener may be invoked when there is a layout pending on the view, affording the listener an opportunity to adjust the upcoming layout based on the selection state.
| Parameters | |
|---|---|
@Nullable OnChildSelectedListener listener |
The listener to be invoked. |
setOnChildViewHolderSelectedListener
public void setOnChildViewHolderSelectedListener(
@Nullable OnChildViewHolderSelectedListener listener
)
Registers a callback to be invoked when an item in BaseGridView has been selected. Note that the listener may be invoked when there is a layout pending on the view, affording the listener an opportunity to adjust the upcoming layout based on the selection state. This method will clear all existing listeners added by addOnChildViewHolderSelectedListener.
| Parameters | |
|---|---|
@Nullable OnChildViewHolderSelectedListener listener |
The listener to be invoked. |
setOnKeyInterceptListener
public void setOnKeyInterceptListener(
@Nullable BaseGridView.OnKeyInterceptListener listener
)
Sets the key intercept listener.
| Parameters | |
|---|---|
@Nullable BaseGridView.OnKeyInterceptListener listener |
The key intercept listener. |
setOnMotionInterceptListener
public void setOnMotionInterceptListener(
@Nullable BaseGridView.OnMotionInterceptListener listener
)
Sets the generic motion intercept listener.
| Parameters | |
|---|---|
@Nullable BaseGridView.OnMotionInterceptListener listener |
The motion intercept listener. |
setOnTouchInterceptListener
public void setOnTouchInterceptListener(
@Nullable BaseGridView.OnTouchInterceptListener listener
)
Sets the touch intercept listener.
| Parameters | |
|---|---|
@Nullable BaseGridView.OnTouchInterceptListener listener |
The touch intercept listener. |
setOnUnhandledKeyListener
public void setOnUnhandledKeyListener(
@Nullable BaseGridView.OnUnhandledKeyListener listener
)
Sets the unhandled key listener.
| Parameters | |
|---|---|
@Nullable BaseGridView.OnUnhandledKeyListener listener |
The unhandled key intercept listener. |
setPruneChild
public void setPruneChild(boolean pruneChild)
Enables or disables pruning of children. Disable is useful during transition.
| Parameters | |
|---|---|
boolean pruneChild |
True to prune children out side visible area, false to enable. |
setSaveChildrenLimitNumber
public final void setSaveChildrenLimitNumber(int limitNumber)
Sets the limit number when getSaveChildrenPolicy is SAVE_LIMITED_CHILD.
setSaveChildrenPolicy
public final void setSaveChildrenPolicy(int savePolicy)
Sets the policy for saving children.
| Parameters | |
|---|---|
int savePolicy |
One of |
setScrollEnabled
public void setScrollEnabled(boolean scrollEnabled)
Enables or disables scrolling. Disable is useful during transition.
| Parameters | |
|---|---|
boolean scrollEnabled |
True to enable scroll, false to disable. |
setSelectedPosition
public void setSelectedPosition(int position)
Changes the selected item immediately without animation.
setSelectedPosition
public void setSelectedPosition(int position, int scrollExtra)
Changes the selected item immediately without animation, scrollExtra is applied in primary scroll direction. The scrollExtra will be kept until another setSelectedPosition or setSelectedPositionSmooth call.
setSelectedPosition
public void setSelectedPosition(int position, @Nullable ViewHolderTask task)
Perform a task on ViewHolder at given position after scroll to it.
| Parameters | |
|---|---|
int position |
Position of item in adapter. |
@Nullable ViewHolderTask task |
Task to executed on the ViewHolder at a given position. |
setSelectedPositionSmooth
public void setSelectedPositionSmooth(int position)
Changes the selected item and run an animation to scroll to the target position.
| Parameters | |
|---|---|
int position |
Adapter position of the item to select. |
setSelectedPositionSmooth
public void setSelectedPositionSmooth(int position, @Nullable ViewHolderTask task)
Perform a task on ViewHolder at given position after smooth scrolling to it.
| Parameters | |
|---|---|
int position |
Position of item in adapter. |
@Nullable ViewHolderTask task |
Task to executed on the ViewHolder at a given position. |
setSmoothScrollByBehavior
public final void setSmoothScrollByBehavior(
@Nullable BaseGridView.SmoothScrollByBehavior behavior
)
Set custom behavior for smoothScrollBy().
| Parameters | |
|---|---|
@Nullable BaseGridView.SmoothScrollByBehavior behavior |
Custom behavior of SmoothScrollBy(). Null for default behavior. |
setSmoothScrollMaxPendingMoves
public final void setSmoothScrollMaxPendingMoves(int maxPendingMoves)
When holding DPAD, DPAD events are generated faster than the grid view can scroll. The grid view counts unhandled DPAD events and completes the movement after user release DPAD. If the value is set too high, the scrolling will last very long after DPAD is released. If the value is set too low, it may miss many DPAD events. The default value is 10. If app increases setSmoothScrollSpeedFactor, it may need decrease the max pending DPAD events to avoid scrolling too long after DPAD release.
| Parameters | |
|---|---|
int maxPendingMoves |
Maximum number of pending DPAD events to be remembered. |
setSmoothScrollSpeedFactor
public final void setSmoothScrollSpeedFactor(float smoothScrollSpeedFactor)
Set factor of how slow the smoothScroller should run. For example when set to 2f, the smooth scroller is twice slower. The value is 1f by default.
| Parameters | |
|---|---|
float smoothScrollSpeedFactor |
Factor of how slow the smooth scroll is. |
public void setVerticalMargin(int margin)Sets the spacing in pixels between two child items vertically.
setVerticalSpacing
public void setVerticalSpacing(int spacing)
Sets the vertical spacing in pixels between two child items.
| Parameters | |
|---|---|
int spacing |
Vertical spacing between two child items. |
setWindowAlignment
public void setWindowAlignment(int windowAlignment)
Sets the method for focused item alignment in the view.
| Parameters | |
|---|---|
int windowAlignment |
|
setWindowAlignmentOffset
public void setWindowAlignmentOffset(int offset)
Sets the offset in pixels for window alignment key line.
| Parameters | |
|---|---|
int offset |
The number of pixels to offset. If the offset is positive, it is distance from low edge (see |
setWindowAlignmentOffsetPercent
public void setWindowAlignmentOffsetPercent(float offsetPercent)
Sets the offset percent for window alignment key line in addition to getWindowAlignmentOffset.
| Parameters | |
|---|---|
float offsetPercent |
Percentage to offset. E.g., 40 means 40% of the width from low edge. Use |
setWindowAlignmentPreferKeyLineOverHighEdge
public void setWindowAlignmentPreferKeyLineOverHighEdge(
boolean preferKeyLineOverHighEdge
)
Returns whether prefer key line over high edge when WINDOW_ALIGN_HIGH_EDGE is used. When true, if there are very few items between high edge and key line, align items to key line instead of align items to high edge. Default value is true (aka prefer align to key line).
| Parameters | |
|---|---|
boolean preferKeyLineOverHighEdge |
True to prefer key line over high edge, false otherwise. |
setWindowAlignmentPreferKeyLineOverLowEdge
public void setWindowAlignmentPreferKeyLineOverLowEdge(
boolean preferKeyLineOverLowEdge
)
Sets whether prefer key line over low edge when WINDOW_ALIGN_LOW_EDGE is used. When true, if there are very few items between low edge and key line, align items to key line instead of align items to low edge. Default value is false (aka prefer align to low edge).
| Parameters | |
|---|---|
boolean preferKeyLineOverLowEdge |
True to prefer key line over low edge, false otherwise. |
smoothScrollBy
public void smoothScrollBy(int dx, int dy)
Animate a scroll by the given amount of pixels along either axis.
| Parameters | |
|---|---|
int dx |
Pixels to scroll horizontally |
int dy |
Pixels to scroll vertically |
smoothScrollBy
public void smoothScrollBy(int dx, int dy, @Nullable Interpolator interpolator)
Animate a scroll by the given amount of pixels along either axis.
| Parameters | |
|---|---|
int dx |
Pixels to scroll horizontally |
int dy |
Pixels to scroll vertically |
@Nullable Interpolator interpolator |
|
smoothScrollToPosition
public void smoothScrollToPosition(int position)
Starts a smooth scroll to an adapter position.
To support smooth scrolling, you must override smoothScrollToPosition and create a SmoothScroller.
LayoutManager is responsible for creating the actual scroll action. If you want to provide a custom smooth scroll logic, override smoothScrollToPosition in your LayoutManager.
| Parameters | |
|---|---|
int position |
The adapter position to scroll to |
| See also | |
|---|---|
smoothScrollToPosition |
Protected methods
dispatchGenericFocusedEvent
protected boolean dispatchGenericFocusedEvent(@NonNull MotionEvent event)
onFocusChanged
protected void onFocusChanged(
boolean gainFocus,
int direction,
@Nullable Rect previouslyFocusedRect
)