public abstract class BaseGridView extends RecyclerView

Known direct subclasses
HorizontalGridView

A android.view.ViewGroup that shows items in a horizontal scrolling list.

VerticalGridView

A android.view.ViewGroup that shows items in a vertically scrolling list.


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

Listener for intercepting key dispatch events.

Interface for receiving notification when BaseGridView has completed a full layout calculation.

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().

Constants

static final float

Value indicates that percent is not used.

static final int

Save 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 getSaveChildrenLimitNumber.

static final int

Dont 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
boolean
@Nullable View
focusSearch(int direction)
int
getChildDrawingOrder(int childCount, int i)
int

This method is deprecated.

Use getHorizontalSpacing

int

Returns the horizontal spacing in pixels between two child items.

int

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.

int

Returns number of pixels to the end of low edge.

float

Returns the offset percent for item alignment in addition to getItemAlignmentOffset.

int

Returns the id of the view to align with, or NO_ID for the root itemView.

@Nullable BaseGridView.OnUnhandledKeyListener

Returns the unhandled key listener.

final int

Returns the limit used when when getSaveChildrenPolicy is SAVE_LIMITED_CHILD

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.

Use getVerticalSpacing

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 getWindowAlignmentOffset.

boolean
boolean

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 getItemAlignmentOffsetPercent is 0 or 100; returns false otherwise.

boolean

Returns true if scrolling is enabled, false otherwise.

boolean

Returns whether prefer key line over high edge when WINDOW_ALIGN_HIGH_EDGE is used.

boolean

Returns whether prefer key line over low edge when WINDOW_ALIGN_LOW_EDGE is used.

boolean
onRequestFocusInDescendants(
    int direction,
    @Nullable Rect previouslyFocusedRect
)
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
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
setHorizontalMargin(int margin)

This method is deprecated.

Use setHorizontalSpacing

void
setHorizontalSpacing(int spacing)

Sets the horizontal spacing in pixels between two child items.

void

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.

void

Sets number of pixels to the end of low edge.

void
setItemAlignmentOffsetPercent(float offsetPercent)

Sets the offset percent for item alignment in addition to getItemAlignmentOffset.

void
setItemAlignmentOffsetWithPadding(boolean withPadding)

Sets whether applies padding to item alignment when getItemAlignmentOffsetPercent is 0 or 100.

void

Sets the id of the view to align with.

void
setItemMargin(int margin)

This method is deprecated.

use setItemSpacing

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 LayoutManager that this RecyclerView will use.

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 getSaveChildrenPolicy is SAVE_LIMITED_CHILD.

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

Perform a task on ViewHolder at given position after scroll to it.

void

Changes the selected item and run an animation to scroll to the target position.

void

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
setVerticalMargin(int margin)

This method is deprecated.

Use setVerticalSpacing

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

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 getWindowAlignmentOffset.

void
setWindowAlignmentPreferKeyLineOverHighEdge(
    boolean preferKeyLineOverHighEdge
)

Returns whether prefer key line over high edge when WINDOW_ALIGN_HIGH_EDGE is used.

void
setWindowAlignmentPreferKeyLineOverLowEdge(
    boolean preferKeyLineOverLowEdge
)

Sets whether prefer key line over low edge when WINDOW_ALIGN_LOW_EDGE is used.

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(
    boolean gainFocus,
    int direction,
    @Nullable Rect previouslyFocusedRect
)

Inherited Constants

From androidx.recyclerview.widget.RecyclerView
static final int
static final int
static final long
NO_ID = -1
static final int
static final int

The RecyclerView is currently being dragged by outside input such as user touch input.

static final int

The RecyclerView is not currently scrolling.

static final int

The RecyclerView is currently animating to a final position while not under outside control.

static final int

Constant for use with setScrollingTouchSlop.

static final int

Constant for use with setScrollingTouchSlop.

static final int
UNDEFINED_DURATION = -2147483648

Constant that represents that a duration has not been defined.

static final int
From android.view.View
static final int
static final int
static final int
static final int
static final int
static final int
static final Property<ViewFloat>
static final int
static final String
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE = "creditCardExpirationDate"
static final String
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY = "creditCardExpirationDay"
static final String
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH = "creditCardExpirationMonth"
static final String
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR = "creditCardExpirationYear"
static final String
static final String
AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE = "creditCardSecurityCode"
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int
static final int
static final int
static final int
static final int
static final int
static final int[]
static final int[]
static final int[]
static final int[]
static final int
static final int
static final int
static final int
static final int
static final int
static final int
GONE = 8
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
KEEP_SCREEN_ON = 67108864
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
NO_ID = -1
static final int
static final int
static final int
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int[]
static final int[]
static final int
static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
static final String
VIEW_LOG_TAG = "View"
static final int
static final int[]
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
From android.view.ViewGroup
static final int
static final int
static final int
static final int
static final int
static final int
static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

Inherited methods

From androidx.core.view.NestedScrollingChild
abstract boolean
dispatchNestedPreScroll(
    int dx,
    int dy,
    @Nullable int[] consumed,
    @Nullable int[] offsetInWindow
)

Dispatch one step of a nested scroll in progress before this view consumes any portion of it.

abstract boolean
dispatchNestedScroll(
    int dxConsumed,
    int dyConsumed,
    int dxUnconsumed,
    int dyUnconsumed,
    @Nullable int[] offsetInWindow
)

Dispatch one step of a nested scroll in progress.

abstract boolean

Begin a nestable scroll operation along the given axes.

From androidx.core.view.NestedScrollingChild2
abstract boolean
dispatchNestedPreScroll(
    int dx,
    int dy,
    @Nullable int[] consumed,
    @Nullable int[] offsetInWindow,
    int type
)

Dispatch one step of a nested scroll in progress before this view consumes any portion of it.

abstract boolean
dispatchNestedScroll(
    int dxConsumed,
    int dyConsumed,
    int dxUnconsumed,
    int dyUnconsumed,
    @Nullable int[] offsetInWindow,
    int type
)

Dispatch one step of a nested scroll in progress.

abstract boolean

Returns true if this view has a nested scrolling parent for the given input type.

abstract boolean
startNestedScroll(int axes, int type)

Begin a nestable scroll operation along the given axes, for the given input type.

abstract void
stopNestedScroll(int type)

Stop a nested scroll in progress for the given input type.

From androidx.core.view.NestedScrollingChild3
abstract void
dispatchNestedScroll(
    int dxConsumed,
    int dyConsumed,
    int dxUnconsumed,
    int dyUnconsumed,
    @Nullable int[] offsetInWindow,
    int type,
    @NonNull int[] consumed
)

Dispatch one step of a nested scroll in progress.

From androidx.recyclerview.widget.RecyclerView
void
addFocusables(ArrayList<View> views, int direction, int focusableMode)
void

Add an ItemDecoration to this RecyclerView.

void

Add an ItemDecoration to this RecyclerView.

void

Register a listener that will be notified whenever a child view is attached to or detached from RecyclerView.

void

Add an OnItemTouchListener to intercept touch events before they are dispatched to child views or this view's standard scrolling behavior.

void

Add a listener that will be notified of any changes in scroll state or position.

void

Register a listener that will be notified whenever a child view is recycled.

boolean
void

Removes all listeners that were added via addOnChildAttachStateChangeListener.

void

Remove all secondary listener that were notified of any changes in scroll state or position.

int

Compute the horizontal extent of the horizontal scrollbar's thumb within the horizontal range.

int

Compute the horizontal offset of the horizontal scrollbar's thumb within the horizontal range.

int

Compute the horizontal range that the horizontal scrollbar represents.

int

Compute the vertical extent of the vertical scrollbar's thumb within the vertical range.

int

Compute the vertical offset of the vertical scrollbar's thumb within the vertical range.

int

Compute the vertical range that the vertical scrollbar represents.

boolean
dispatchNestedFling(float velocityX, float velocityY, boolean consumed)
boolean
dispatchNestedPreFling(float velocityX, float velocityY)
boolean
dispatchNestedPreScroll(
    int dx,
    int dy,
    int[] consumed,
    int[] offsetInWindow
)
boolean
dispatchNestedPreScroll(
    int dx,
    int dy,
    int[] consumed,
    int[] offsetInWindow,
    int type
)

Dispatch one step of a nested scroll in progress before this view consumes any portion of it.

boolean
dispatchNestedScroll(
    int dxConsumed,
    int dyConsumed,
    int dxUnconsumed,
    int dyUnconsumed,
    int[] offsetInWindow
)
boolean
dispatchNestedScroll(
    int dxConsumed,
    int dyConsumed,
    int dxUnconsumed,
    int dyUnconsumed,
    int[] offsetInWindow,
    int type
)

Dispatch one step of a nested scroll in progress.

final void
dispatchNestedScroll(
    int dxConsumed,
    int dyConsumed,
    int dxUnconsumed,
    int dyUnconsumed,
    int[] offsetInWindow,
    int type,
    @NonNull int[] consumed
)

Dispatch one step of a nested scroll in progress.

boolean
void

Override to prevent thawing of any views created by the adapter.

void

Override to prevent freezing of any views created by the adapter.

void
boolean
drawChild(@NonNull Canvas canvas, View child, long drawingTime)
@Nullable View
findChildViewUnder(float x, float y)

Find the topmost view under the given point.

@Nullable View

Traverses the ancestors of the given view and returns the item view that contains it and also a direct child of the RecyclerView.

@Nullable RecyclerView.ViewHolder

Returns the ViewHolder that contains the given view.

@Nullable RecyclerView.ViewHolder

Return the ViewHolder for the item in the given position of the data set.

RecyclerView.ViewHolder

Return the ViewHolder for the item with the given id.

@Nullable RecyclerView.ViewHolder

Return the ViewHolder for the item in the given position of the data set as of the latest layout pass.

@Nullable RecyclerView.ViewHolder

This method is deprecated.

use findViewHolderForLayoutPosition or findViewHolderForAdapterPosition

boolean
fling(int velocityX, int velocityY)

Begin a standard fling with an initial velocity along each axis in pixels per second.

View
focusSearch(View focused, int direction)

Since RecyclerView is a collection ViewGroup that includes virtual children (items that are in the Adapter but not visible in the UI), it employs a more involved focus search strategy that differs from other ViewGroups.

ViewGroup.LayoutParams
ViewGroup.LayoutParams
ViewGroup.LayoutParams
CharSequence
@Nullable RecyclerView.Adapter

Retrieves the previously set adapter or null if no adapter is set.

int

Return the offset of the RecyclerView's text baseline from the its top boundary.

int

Return the adapter position that the given child view corresponds to.

long

Return the stable item id that the given child view corresponds to.

int

Return the adapter position of the given child view as of the latest completed layout pass.

int

This method is deprecated.

use getChildAdapterPosition or getChildLayoutPosition.

RecyclerView.ViewHolder

Retrieve the ViewHolder for the given child view.

boolean

Returns whether this RecyclerView will clip its children to its padding, and resize (but not clip) any EdgeEffect to the padded region, if padding is present.

@Nullable RecyclerViewAccessibilityDelegate

Returns the accessibility delegate compatibility implementation used by the RecyclerView.

void

Returns the bounds of the view including its decoration and margins.

@NonNull RecyclerView.EdgeEffectFactory

Retrieves the previously set EdgeEffectFactory or the default factory if nothing was set.

@Nullable RecyclerView.ItemAnimator

Gets the current ItemAnimator for this RecyclerView.

@NonNull RecyclerView.ItemDecoration

Returns an ItemDecoration previously added to this RecyclerView.

int

Returns the number of ItemDecoration currently added to this RecyclerView.

@Nullable RecyclerView.LayoutManager

Return the LayoutManager currently responsible for layout policy for this RecyclerView.

int

Returns the maximum fling velocity used by this RecyclerView.

int

Returns the minimum velocity to start a fling.

@Nullable RecyclerView.OnFlingListener

Get the current OnFlingListener from this RecyclerView.

boolean

Returns true if the RecyclerView should attempt to preserve currently focused Adapter Item's focus even if the View representing the Item is replaced during a layout calculation.

@NonNull RecyclerView.RecycledViewPool

Retrieve this RecyclerView's RecycledViewPool.

int

Return the current scrolling state of the RecyclerView.

boolean
boolean
boolean

Returns true if this view has a nested scrolling parent for the given input type.

boolean

Returns whether there are pending adapter updates which are not yet applied to the layout.

void

Invalidates all ItemDecorations.

boolean

Returns true if RecyclerView is currently running some animations.

boolean

Returns true if RecyclerView is attached to window.

boolean

Returns whether RecyclerView is currently computing a layout.

boolean

This method is deprecated.

Use isLayoutSuppressed.

final boolean

Returns whether layout and scroll calls on this container are currently being suppressed, due to an earlier call to suppressLayout.

boolean
void
nestedScrollBy(int x, int y)

Same as scrollBy, but also participates in nested scrolling.

void

Offset the bounds of all child views by dx pixels.

void

Offset the bounds of all child views by dy pixels.

void
void

Called when an item view is attached to this RecyclerView.

void

Called when an item view is detached from this RecyclerView.

void
void
boolean
boolean
void
onLayout(boolean changed, int l, int t, int r, int b)
void
onMeasure(int widthSpec, int heightSpec)
void
Parcelable
void

Called when the scroll state of this RecyclerView changes.

void
onScrolled(@Px int dx, @Px int dy)

Called when the scroll position of this RecyclerView changes.

void
onSizeChanged(int w, int h, int oldw, int oldh)
boolean
void
removeDetachedView(View child, boolean animate)
void

Remove an ItemDecoration from this RecyclerView.

void

Removes the ItemDecoration associated with the supplied index position.

void

Removes the provided listener from child attached state listeners list.

void

Remove an OnItemTouchListener.

void

Remove a listener that was notified of any changes in scroll state or position.

void

Removes the provided listener from RecyclerListener list.

void
requestChildFocus(View child, View focused)
boolean
requestChildRectangleOnScreen(View child, Rect rect, boolean immediate)
void
requestDisallowInterceptTouchEvent(boolean disallowIntercept)
void
void
scrollBy(int x, int y)
void
scrollTo(int x, int y)
void
void

Sets the accessibility delegate compatibility implementation used by RecyclerView.

void

Set a new adapter to provide child views on demand.

void

Sets the ChildDrawingOrderCallback to be used for drawing children.

void
setClipToPadding(boolean clipToPadding)
static void
setDebugAssertionsEnabled(boolean debugAssertionsEnabled)

Enable internal assertions about RecyclerView's state and throw exceptions if the assertions are violated.

void

Set a EdgeEffectFactory for this RecyclerView.

void
setHasFixedSize(boolean hasFixedSize)

RecyclerView can perform several optimizations if it can know in advance that RecyclerView's size is not affected by the adapter contents.

void

Sets the ItemAnimator that will handle animations involving changes to the items in this RecyclerView.

void

Set the number of offscreen views to retain before adding them to the potentially shared recycled view pool.

void
setLayoutFrozen(boolean frozen)

This method is deprecated.

Use suppressLayout.

void

This method is deprecated.

Use setItemAnimator ()}.

void
setNestedScrollingEnabled(boolean enabled)
void

Set a OnFlingListener for this RecyclerView.

void

This method is deprecated.

Use addOnScrollListener and removeOnScrollListener

void
setPreserveFocusAfterLayout(boolean preserveFocusAfterLayout)

Set whether the RecyclerView should try to keep the same Item focused after a layout calculation or not.

void

Recycled view pools allow multiple RecyclerViews to share a common pool of scrap views.

void

This method is deprecated.

Use addRecyclerListener and removeRecyclerListener

void
setScrollingTouchSlop(int slopConstant)

Configure the scrolling touch slop for a specific use case.

static void
setVerboseLoggingEnabled(boolean verboseLoggingEnabled)

Enable verbose logging within RecyclerView itself.

void

Sets a new ViewCacheExtension to be used by the Recycler.

void
smoothScrollBy(
    @Px int dx,
    @Px int dy,
    @Nullable Interpolator interpolator,
    int duration
)

Smooth scrolls the RecyclerView by a given distance.

boolean
boolean
startNestedScroll(int axes, int type)

Begin a nestable scroll operation along the given axes, for the given input type.

void
void
stopNestedScroll(int type)

Stop a nested scroll in progress for the given input type.

void

Stop any current scroll in progress, such as one started by smoothScrollBy, fling or a touch-initiated fling.

final void
suppressLayout(boolean suppress)

Tells this RecyclerView to suppress all layout and scroll calls until layout suppression is disabled with a later call to suppressLayout(false).

void
swapAdapter(
    @Nullable RecyclerView.Adapter adapter,
    boolean removeAndRecycleExistingViews
)

Swaps the current adapter with the provided one.

From android.view.View
void
void
void
ViewPropertyAnimator
void
void
boolean
void
void

This method is deprecated.

void
boolean
boolean
boolean
boolean
boolean
canScrollHorizontally(int direction)
boolean
canScrollVertically(int direction)
final void
void
final void
boolean
void
void
static int
combineMeasuredStates(int curState, int newState)
int
int
int
void
WindowInsets
int
int
int
AccessibilityNodeInfo
void
void

This method is deprecated.

boolean
boolean
dispatchNestedFling(float velocityX, float velocityY, boolean consumed)
boolean
dispatchNestedPreFling(float velocityX, float velocityY)
boolean
dispatchNestedPrePerformAccessibilityAction(
    int action,
    Bundle arguments
)
boolean
dispatchNestedPreScroll(
    int dx,
    int dy,
    int[] consumed,
    int[] offsetInWindow
)
boolean
dispatchNestedScroll(
    int dxConsumed,
    int dyConsumed,
    int dxUnconsumed,
    int dyUnconsumed,
    int[] offsetInWindow
)
boolean
void
draw(Canvas canvas)
void
drawableHotspotChanged(float x, float y)
final OnBackInvokedDispatcher
final T
<T extends View> findViewById(int id)
final T
<T extends View> findViewWithTag(Object tag)
boolean

This method is deprecated.

void
forceHasOverlappingRendering(boolean hasOverlappingRendering)
void
void
generateDisplayHash(
    String hashAlgorithm,
    Rect bounds,
    Executor executor,
    DisplayHashResultCallback callback
)
static int
View.AccessibilityDelegate
int
AccessibilityNodeProvider
CharSequence
int
int
String
String
float
Animation
Matrix
IBinder
int[]
Map<IntegerInteger>
String[]
final AutofillId
int
AutofillValue
Drawable
BlendMode
ColorStateList
PorterDuff.Mode
int
final int
float
int
float
Rect
boolean
final boolean
final ContentCaptureSession
CharSequence
final Context
ContextMenu.ContextMenuInfo
final boolean
static int
getDefaultSize(int size, int measureSpec)
Display
final int[]
Bitmap

This method is deprecated.

int

This method is deprecated.

int

This method is deprecated.

void
long
float
int
boolean
boolean
int
ArrayList<View>
getFocusables(int direction)
void
Drawable
int
BlendMode
ColorStateList
PorterDuff.Mode
boolean
getGlobalVisibleRect(Rect r, Point globalOffset)
Handler
float
float
float
float
Runnable
final boolean
final int
void
getHitRect(Rect outRect)
int
int
Drawable
Drawable
int
int
int
int
boolean
KeyEvent.DispatcherState
int
int
int
ViewGroup.LayoutParams
final int
float
int
final boolean
void
getLocationInSurface(int[] location)
void
getLocationInWindow(int[] outLocation)
void
getLocationOnScreen(int[] outLocation)
Matrix
final int
final int
final int
final int
final int
int
int
int
int
int
int
int
int
View.OnFocusChangeListener
int
ViewOutlineProvider
int
int
ViewOverlay
int
int
int
int
int
int
final ViewParent
ViewParent
float
float
PointerIcon
final List<Rect>
String[]
Resources
final boolean
final int
float
int
AttachedSurfaceControl
View
WindowInsets
float
float
float
float
float
int
int
int
int
int
int
final int
final int
int
int
final CharSequence
StateListAnimator
int
int
List<Rect>
int

This method is deprecated.

Object
int
int
CharSequence
final int
float
int
TouchDelegate
ArrayList<View>
float
String
float
float
float
long
int
int
Drawable
Drawable
int
ViewTranslationResponse
ViewTreeObserver
int
final int
int
WindowId
WindowInsetsController
int

This method is deprecated.

IBinder
int
void
float
float
float
boolean
boolean
boolean
boolean
boolean
boolean
boolean
static View
inflate(Context context, int resource, ViewGroup root)
void

This method is deprecated.

void
void
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean

This method is deprecated.

boolean
boolean
final boolean
final boolean
boolean
final boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
final boolean
final boolean
boolean
boolean
boolean
final boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
final boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
final boolean
boolean
boolean
final boolean
boolean
boolean
boolean
boolean
boolean
View
keyboardNavigationClusterSearch(View currentCluster, int direction)
final void
measure(int widthMeasureSpec, int heightMeasureSpec)
static int[]
mergeDrawableStates(int[] baseState, int[] additionalState)
void
offsetLeftAndRight(int offset)
void
offsetTopAndBottom(int offset)
void
void
WindowInsets
void
boolean
boolean
void
void
InputConnection
void
onCreateViewTranslationRequest(
    int[] supportedFormats,
    Consumer<ViewTranslationRequest> requestsCollector
)
void
onCreateVirtualViewTranslationRequests(
    long[] virtualIds,
    int[] supportedFormats,
    Consumer<ViewTranslationRequest> requestsCollector
)
void
onDisplayHint(int hint)
boolean
void
onDraw(Canvas canvas)
void
final void
boolean
void
void
boolean
void
onHoverChanged(boolean hovered)
boolean
void
void
boolean
onKeyDown(int keyCode, KeyEvent event)
boolean
onKeyLongPress(int keyCode, KeyEvent event)
boolean
onKeyMultiple(int keyCode, int repeatCount, KeyEvent event)
boolean
onKeyPreIme(int keyCode, KeyEvent event)
boolean
onKeyShortcut(int keyCode, KeyEvent event)
boolean
onKeyUp(int keyCode, KeyEvent event)
void
onMeasure(int widthMeasureSpec, int heightMeasureSpec)
void
onOverScrolled(
    int scrollX,
    int scrollY,
    boolean clampedX,
    boolean clampedY
)
void
onPointerCaptureChange(boolean hasCapture)
void
void
onProvideAutofillStructure(ViewStructure structure, int flags)
void
void
void
void
ContentInfo
void
Parcelable
void
onScreenStateChanged(int screenState)
void
onScrollCaptureSearch(
    Rect localVisibleRect,
    Point windowOffset,
    Consumer<ScrollCaptureTarget> targets
)
void
onScrollChanged(int l, int t, int oldl, int oldt)
boolean
onSetAlpha(int alpha)
void
onSizeChanged(int w, int h, int oldw, int oldh)
void
boolean
boolean
void
void
void
onVisibilityAggregated(boolean isVisible)
void
onVisibilityChanged(View changedView, int visibility)
void
onWindowFocusChanged(boolean hasWindowFocus)
void

This method is deprecated.

void
onWindowVisibilityChanged(int visibility)
boolean
overScrollBy(
    int deltaX,
    int deltaY,
    int scrollX,
    int scrollY,
    int scrollRangeX,
    int scrollRangeY,
    int maxOverScrollX,
    int maxOverScrollY,
    boolean isTouchEvent
)
boolean
performAccessibilityAction(int action, Bundle arguments)
boolean
boolean
performContextClick(float x, float y)
boolean
performHapticFeedback(int feedbackConstant)
boolean
ContentInfo
void
playSoundEffect(int soundConstant)
boolean
post(Runnable action)
boolean
postDelayed(Runnable action, long delayMillis)
void
void
postInvalidateDelayed(long delayMilliseconds)
void
void
void
postOnAnimationDelayed(Runnable action, long delayMillis)
void
void
boolean
void
void
void
void
void

This method is deprecated.

final boolean
void
void
boolean
final void
final T
<T extends View> requireViewById(int id)
void
static int
resolveSize(int size, int measureSpec)
static int
resolveSizeAndState(int size, int measureSpec, int childMeasuredState)
void
final void
saveAttributeDataForStyleable(
    Context context,
    int[] styleable,
    AttributeSet attrs,
    TypedArray t,
    int defStyleAttr,
    int defStyleRes
)
void
void
scheduleDrawable(Drawable who, Runnable what, long when)
void
scrollBy(int x, int y)
void
scrollTo(int x, int y)
void
sendAccessibilityEvent(int eventType)
void
void
setAccessibilityDataSensitive(int accessibilityDataSensitive)
void
void
setAccessibilityHeading(boolean isHeading)
void
void
setAccessibilityPaneTitle(CharSequence accessibilityPaneTitle)
void
void
void
setActivated(boolean activated)
void
setAllowClickWhenDisabled(boolean clickableWhenDisabled)
void
void
void
setAlpha(float alpha)
void
void
void
setAutoHandwritingEnabled(boolean enabled)
void
setAutofillHints(String[] autofillHints)
void
void
setBackground(Drawable background)
void
setBackgroundColor(int color)
void

This method is deprecated.

void
void
void
void
final void
setBottom(int bottom)
void
setCameraDistance(float distance)
void
setClickable(boolean clickable)
void
setClipBounds(Rect clipBounds)
void
setClipToOutline(boolean clipToOutline)
void
void
setContentDescription(CharSequence contentDescription)
void
setContextClickable(boolean contextClickable)
void
setDefaultFocusHighlightEnabled(boolean defaultFocusHighlightEnabled)
void

This method is deprecated.

void
setDrawingCacheEnabled(boolean enabled)

This method is deprecated.

void

This method is deprecated.

void
void
setElevation(float elevation)
void
setEnabled(boolean enabled)
void
setFadingEdgeLength(int length)
void
void
setFitsSystemWindows(boolean fitSystemWindows)
void
setFocusable(boolean focusable)
void
setFocusableInTouchMode(boolean focusableInTouchMode)
void
setFocusedByDefault(boolean isFocusedByDefault)
void
setForceDarkAllowed(boolean allow)
void
setForeground(Drawable foreground)
void
setForegroundGravity(int gravity)
void
void
void
void
setHandwritingBoundsOffsets(
    float offsetLeft,
    float offsetTop,
    float offsetRight,
    float offsetBottom
)
void
void
setHapticFeedbackEnabled(boolean hapticFeedbackEnabled)
void
setHasTransientState(boolean hasTransientState)
void
setHorizontalFadingEdgeEnabled(boolean horizontalFadingEdgeEnabled)
void
setHorizontalScrollBarEnabled(boolean horizontalScrollBarEnabled)
void
void
void
setHovered(boolean hovered)
void
setId(int id)
void
void
void
void
setIsCredential(boolean isCredential)
void
setIsHandwritingDelegate(boolean isHandwritingDelegate)
void
setKeepScreenOn(boolean keepScreenOn)
void
setKeyboardNavigationCluster(boolean isCluster)
void
setLabelFor(int id)
void
void
setLayerType(int layerType, Paint paint)
void
setLayoutDirection(int layoutDirection)
void
final void
setLeft(int left)
final void
setLeftTopRightBottom(int left, int top, int right, int bottom)
void
setLongClickable(boolean longClickable)
final void
setMeasuredDimension(int measuredWidth, int measuredHeight)
void
setMinimumHeight(int minHeight)
void
setMinimumWidth(int minWidth)
void
setNestedScrollingEnabled(boolean enabled)
void
setNextClusterForwardId(int nextClusterForwardId)
void
setNextFocusDownId(int nextFocusDownId)
void
setNextFocusForwardId(int nextFocusForwardId)
void
setNextFocusLeftId(int nextFocusLeftId)
void
setNextFocusRightId(int nextFocusRightId)
void
setNextFocusUpId(int nextFocusUpId)
void
void
void
void
void
void
void
void
void
void
void
void
setOnReceiveContentListener(
    String[] mimeTypes,
    OnReceiveContentListener listener
)
void
void

This method is deprecated.

void
void
void
void
void
setOverScrollMode(int overScrollMode)
void
setPadding(int left, int top, int right, int bottom)
void
setPaddingRelative(int start, int top, int end, int bottom)
void
setPivotX(float pivotX)
void
setPivotY(float pivotY)
void
final void
setPreferKeepClear(boolean preferKeepClear)
final void
void
setPressed(boolean pressed)
void
final void
setRevealOnFocusHint(boolean revealOnFocus)
final void
setRight(int right)
void
setRotation(float rotation)
void
setRotationX(float rotationX)
void
setRotationY(float rotationY)
void
setSaveEnabled(boolean enabled)
void
setSaveFromParentEnabled(boolean enabled)
void
setScaleX(float scaleX)
void
setScaleY(float scaleY)
void
setScreenReaderFocusable(boolean screenReaderFocusable)
void
setScrollBarDefaultDelayBeforeFade(
    int scrollBarDefaultDelayBeforeFade
)
void
setScrollBarFadeDuration(int scrollBarFadeDuration)
void
setScrollBarSize(int scrollBarSize)
void
setScrollBarStyle(int style)
final void
void
void
setScrollContainer(boolean isScrollContainer)
void
setScrollIndicators(int indicators)
void
setScrollX(int value)
void
setScrollY(int value)
void
setScrollbarFadingEnabled(boolean fadeScrollbars)
void
setSelected(boolean selected)
void
setSoundEffectsEnabled(boolean soundEffectsEnabled)
void
void
void
void
setSystemUiVisibility(int visibility)

This method is deprecated.

void
void
setTextAlignment(int textAlignment)
void
setTextDirection(int textDirection)
void
final void
setTop(int top)
void
void
setTransitionAlpha(float alpha)
final void
setTransitionName(String transitionName)
void
setTransitionVisibility(int visibility)
void
setTranslationX(float translationX)
void
setTranslationY(float translationY)
void
setTranslationZ(float translationZ)
void
setVerticalFadingEdgeEnabled(boolean verticalFadingEdgeEnabled)
void
setVerticalScrollBarEnabled(boolean verticalScrollBarEnabled)
void
void
void
void
void
setVisibility(int visibility)
void
setWillNotCacheDrawing(boolean willNotCacheDrawing)

This method is deprecated.

void
setWillNotDraw(boolean willNotDraw)
void
setX(float x)
void
setY(float y)
void
setZ(float z)
boolean
ActionMode
void
final boolean
startDrag(
    ClipData data,
    View.DragShadowBuilder shadowBuilder,
    Object myLocalState,
    int flags
)

This method is deprecated.

final boolean
startDragAndDrop(
    ClipData data,
    View.DragShadowBuilder shadowBuilder,
    Object myLocalState,
    int flags
)
boolean
void
String
void
void
void
final void
boolean
boolean

This method is deprecated.

boolean
From android.view.ViewGroup
void
void
addExtraDataToAccessibilityNodeInfo(
    AccessibilityNodeInfo info,
    String extraDataKey,
    Bundle arguments
)
void
addFocusables(ArrayList<View> views, int direction, int focusableMode)
void
boolean
void
void
addView(View child)
boolean
addViewInLayout(View child, int index, ViewGroup.LayoutParams params)
void
attachLayoutAnimationParameters(
    View child,
    ViewGroup.LayoutParams params,
    int index,
    int count
)
void
attachViewToParent(View child, int index, ViewGroup.LayoutParams params)
void
boolean
boolean
void
void
childHasTransientStateChanged(
    View child,
    boolean childHasTransientState
)
void
void
void
void
void
debug(int depth)
void
void
void
detachViewsFromParent(int start, int count)
WindowInsets
boolean
void
void
dispatchCreateViewTranslationRequest(
    Map<AutofillId, long[]> viewIds,
    int[] supportedFormats,
    TranslationCapability capability,
    List<ViewTranslationRequest> requests
)
void
boolean
void
void
dispatchDrawableHotspotChanged(float x, float y)
void
void
boolean
boolean
boolean
boolean
boolean
void
dispatchPointerCaptureChanged(boolean hasCapture)
void
void
void
void
void
dispatchScrollCaptureSearch(
    Rect localVisibleRect,
    Point windowOffset,
    Consumer<ScrollCaptureTarget> targets
)
void
dispatchSetActivated(boolean activated)
void
dispatchSetPressed(boolean pressed)
void
dispatchSetSelected(boolean selected)
void
void

This method is deprecated.

void
boolean
boolean
dispatchUnhandledMove(View focused, int direction)
void
dispatchVisibilityChanged(View changedView, int visibility)
void
dispatchWindowFocusChanged(boolean hasFocus)
void
void
WindowInsets
WindowInsetsAnimation.Bounds
void

This method is deprecated.

void
boolean
drawChild(Canvas canvas, View child, long drawingTime)
void
void
View
OnBackInvokedDispatcher
void
findViewsWithText(
    ArrayList<View> outViews,
    CharSequence text,
    int flags
)
View
focusSearch(View focused, int direction)
void
boolean
ViewGroup.LayoutParams
ViewGroup.LayoutParams
CharSequence
View
getChildAt(int index)
int
int
getChildDrawingOrder(int childCount, int drawingPosition)
static int
getChildMeasureSpec(int spec, int padding, int childDimension)
boolean
boolean
getChildVisibleRect(View child, Rect r, Point offset)
boolean
boolean
int
View
LayoutAnimationController
Animation.AnimationListener
int
LayoutTransition
int
ViewGroupOverlay
int

This method is deprecated.

boolean
boolean
boolean
int
final void
invalidateChild(View child, Rect dirty)

This method is deprecated.

ViewParent
invalidateChildInParent(int[] location, Rect dirty)

This method is deprecated.

boolean

This method is deprecated.

boolean

This method is deprecated.

boolean
boolean

This method is deprecated.

boolean
boolean
boolean
void
final void
layout(int l, int t, int r, int b)
void
measureChild(
    View child,
    int parentWidthMeasureSpec,
    int parentHeightMeasureSpec
)
void
measureChildWithMargins(
    View child,
    int parentWidthMeasureSpec,
    int widthUsed,
    int parentHeightMeasureSpec,
    int heightUsed
)
void
measureChildren(int widthMeasureSpec, int heightMeasureSpec)
void
notifySubtreeAccessibilityStateChanged(
    View child,
    View source,
    int changeType
)
final void
final void
void
int[]
onCreateDrawableState(int extraSpace)
void
void
boolean
boolean
abstract void
onLayout(boolean p, int p1, int p2, int p3, int p4)
boolean
onNestedFling(
    View target,
    float velocityX,
    float velocityY,
    boolean consumed
)
boolean
onNestedPreFling(View target, float velocityX, float velocityY)
boolean
onNestedPrePerformAccessibilityAction(
    View target,
    int action,
    Bundle args
)
void
onNestedPreScroll(View target, int dx, int dy, int[] consumed)
void
onNestedScroll(
    View target,
    int dxConsumed,
    int dyConsumed,
    int dxUnconsumed,
    int dyUnconsumed
)
void
onNestedScrollAccepted(View child, View target, int axes)
boolean
onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect)
boolean
PointerIcon
onResolvePointerIcon(MotionEvent event, int pointerIndex)
boolean
onStartNestedScroll(View child, View target, int nestedScrollAxes)
void
void
void
void
void
void
void
removeDetachedView(View child, boolean animate)
void
void
removeViews(int start, int count)
void
removeViewsInLayout(int start, int count)
void
requestChildFocus(View child, View focused)
boolean
requestChildRectangleOnScreen(
    View child,
    Rect rectangle,
    boolean immediate
)
void
requestDisallowInterceptTouchEvent(boolean disallowIntercept)
boolean
requestFocus(int direction, Rect previouslyFocusedRect)
boolean
void
boolean
void
void
setAddStatesFromChildren(boolean addsStates)
void

This method is deprecated.

void
setAnimationCacheEnabled(boolean enabled)

This method is deprecated.

void

This method is deprecated.

void
void

This method is deprecated.

void
setClipChildren(boolean clipChildren)
void
setClipToPadding(boolean clipToPadding)
void
setDescendantFocusability(int focusability)
void
void
void
setLayoutMode(int layoutMode)
void
void
void
void
setPersistentDrawingCache(int drawingCacheToKeep)

This method is deprecated.

void
void
setTouchscreenBlocksFocus(boolean touchscreenBlocksFocus)
void
setTransitionGroup(boolean isTransitionGroup)
void
boolean
boolean
ActionMode
startActionModeForChild(
    View originalView,
    ActionMode.Callback callback
)
void
void
void
suppressLayout(boolean suppress)
void

Constants

ITEM_ALIGN_OFFSET_PERCENT_DISABLED

Added in 1.0.0-alpha03
public static final float ITEM_ALIGN_OFFSET_PERCENT_DISABLED = -1.0f

Value indicates that percent is not used.

SAVE_ALL_CHILD

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
public static final int SAVE_NO_CHILD = 0

Dont save states of any child views.

SAVE_ON_SCREEN_CHILD

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
public static final float WINDOW_ALIGN_OFFSET_PERCENT_DISABLED = -1.0f

Value indicates that percent is not used.

Public methods

addOnChildViewHolderSelectedListener

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
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.

animateIn

Added in 1.0.0-alpha03
public void animateIn()

Undo animateOut() and slide in child views.

animateOut

Added in 1.0.0-alpha03
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.

dispatchKeyEvent

public boolean dispatchKeyEvent(@NonNull KeyEvent event)

dispatchTouchEvent

public boolean dispatchTouchEvent(@NonNull MotionEvent event)

focusSearch

public @Nullable View focusSearch(int direction)

getChildDrawingOrder

Added in 1.0.0-alpha03
public int getChildDrawingOrder(int childCount, int i)

getHorizontalMargin

Added in 1.0.0-alpha03
Deprecated in 1.0.0-alpha03
public int getHorizontalMargin()

Returns the spacing in pixels between two child items horizontally.

getHorizontalSpacing

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
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 ITEM_ALIGN_OFFSET_PERCENT_DISABLED if disabled. Default value is 50.

getItemAlignmentViewId

Added in 1.0.0-alpha03
public int getItemAlignmentViewId()

Returns the id of the view to align with, or NO_ID for the root itemView.

Returns
int

The id of the view to align with, or NO_ID for the root itemView.

getOnUnhandledKeyListener

Added in 1.0.0-alpha03
public @Nullable BaseGridView.OnUnhandledKeyListener getOnUnhandledKeyListener()

Returns the unhandled key listener.

Returns
@Nullable BaseGridView.OnUnhandledKeyListener

The unhandled key listener.

getSaveChildrenLimitNumber

Added in 1.0.0-alpha03
public final int getSaveChildrenLimitNumber()

Returns the limit used when when getSaveChildrenPolicy is SAVE_LIMITED_CHILD

getSaveChildrenPolicy

Added in 1.0.0-alpha03
public final int getSaveChildrenPolicy()

Returns the policy for saving children.

getSelectedPosition

Added in 1.0.0-alpha03
public int getSelectedPosition()

Returns the adapter position of selected item.

Returns
int

The adapter position of selected item.

getSmoothScrollByBehavior

Added in 1.0.0-alpha03
public @Nullable BaseGridView.SmoothScrollByBehavior getSmoothScrollByBehavior()

Returns custom behavior for smoothScrollBy().

Returns
@Nullable BaseGridView.SmoothScrollByBehavior

Custom behavior for SmoothScrollBy(). Null for default behavior.

getSmoothScrollMaxPendingMoves

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
public final float getSmoothScrollSpeedFactor()
Returns
float

Factor of how slow the smoothScroller runs. Default value is 1f.

getVerticalMargin

Added in 1.0.0-alpha03
Deprecated in 1.0.0-alpha03
public int getVerticalMargin()

Returns the spacing in pixels between two child items vertically.

getVerticalSpacing

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
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.

Parameters
@NonNull View view

The view to get offsets.

@NonNull int[] offsets

offsets[0] holds offset of X, offsets[1] holds offset of Y.

getWindowAlignment

Added in 1.0.0-alpha03
public int getWindowAlignment()

Returns the method for focused item alignment in the view.

getWindowAlignmentOffset

Added in 1.0.0-alpha03
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 WINDOW_ALIGN_LOW_EDGE); if the offset is negative, the absolute value is distance from high edge (see WINDOW_ALIGN_HIGH_EDGE). Default value is 0.

getWindowAlignmentOffsetPercent

Added in 1.0.0-alpha03
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 WINDOW_ALIGN_OFFSET_PERCENT_DISABLED if disabled. Default value is 50.

hasOverlappingRendering

public boolean hasOverlappingRendering()

hasPreviousViewInSameRow

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
public final boolean isFocusSearchDisabled()

Returns true if focus search is disabled.

Returns
boolean

True if focus search is disabled.

isItemAlignmentOffsetWithPadding

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
public boolean isScrollEnabled()

Returns true if scrolling is enabled, false otherwise.

Returns
boolean

True if scrolling is enabled, false otherwise.

isWindowAlignmentPreferKeyLineOverHighEdge

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
public boolean onRequestFocusInDescendants(
    int direction,
    @Nullable Rect previouslyFocusedRect
)

onRtlPropertiesChanged

public void onRtlPropertiesChanged(int layoutDirection)

Notify layout manager that layout directionality has been updated

removeOnChildViewHolderSelectedListener

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
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.

removeView

public void removeView(@NonNull View view)

removeViewAt

public void removeViewAt(int index)

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

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
public void setChildrenVisibility(int visibility)

Changes and overrides children's visibility.

Parameters
int visibility

See getVisibility.

setFocusDrawingOrderEnabled

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
public final void setFocusSearchDisabled(boolean disabled)

Disables or enables focus search.

Parameters
boolean disabled

True to disable focus search, false to enable.

setGravity

Added in 1.0.0-alpha03
public void setGravity(int gravity)

Sets the gravity used for child view positioning. Defaults to GRAVITY_TOP|GRAVITY_START.

Parameters
int gravity

See android.view.Gravity

setHasOverlappingRendering

Added in 1.0.0-alpha03
public void setHasOverlappingRendering(boolean hasOverlapping)

setHorizontalMargin

Added in 1.0.0-alpha03
Deprecated in 1.0.0-alpha03
public void setHorizontalMargin(int margin)

Sets the spacing in pixels between two child items horizontally.

setHorizontalSpacing

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
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 ITEM_ALIGN_OFFSET_PERCENT_DISABLED to disable.

setItemAlignmentOffsetWithPadding

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
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.

setItemMargin

Added in 1.0.0-alpha03
Deprecated in 1.0.0-alpha03
public void setItemMargin(int margin)

Sets the spacing in pixels between two child items.

setItemSpacing

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
public void setOnKeyInterceptListener(
    @Nullable BaseGridView.OnKeyInterceptListener listener
)

Sets the key intercept listener.

Parameters
@Nullable BaseGridView.OnKeyInterceptListener listener

The key intercept listener.

setOnMotionInterceptListener

Added in 1.0.0-alpha03
public void setOnMotionInterceptListener(
    @Nullable BaseGridView.OnMotionInterceptListener listener
)

Sets the generic motion intercept listener.

Parameters
@Nullable BaseGridView.OnMotionInterceptListener listener

The motion intercept listener.

setOnTouchInterceptListener

Added in 1.0.0-alpha03
public void setOnTouchInterceptListener(
    @Nullable BaseGridView.OnTouchInterceptListener listener
)

Sets the touch intercept listener.

Parameters
@Nullable BaseGridView.OnTouchInterceptListener listener

The touch intercept listener.

setOnUnhandledKeyListener

Added in 1.0.0-alpha03
public void setOnUnhandledKeyListener(
    @Nullable BaseGridView.OnUnhandledKeyListener listener
)

Sets the unhandled key listener.

Parameters
@Nullable BaseGridView.OnUnhandledKeyListener listener

The unhandled key intercept listener.

setPruneChild

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
public final void setSaveChildrenLimitNumber(int limitNumber)

Sets the limit number when getSaveChildrenPolicy is SAVE_LIMITED_CHILD.

setSaveChildrenPolicy

Added in 1.0.0-alpha03
public final void setSaveChildrenPolicy(int savePolicy)

Sets the policy for saving children.

setScrollEnabled

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
public void setSelectedPosition(int position)

Changes the selected item immediately without animation.

setSelectedPosition

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
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.

setVerticalMargin

Added in 1.0.0-alpha03
Deprecated in 1.0.0-alpha03
public void setVerticalMargin(int margin)

Sets the spacing in pixels between two child items vertically.

setVerticalSpacing

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
public void setWindowAlignment(int windowAlignment)

Sets the method for focused item alignment in the view.

setWindowAlignmentOffset

Added in 1.0.0-alpha03
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 WINDOW_ALIGN_LOW_EDGE); if the offset is negative, the absolute value is distance from high edge (see WINDOW_ALIGN_HIGH_EDGE). Default value is 0.

setWindowAlignmentOffsetPercent

Added in 1.0.0-alpha03
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 WINDOW_ALIGN_OFFSET_PERCENT_DISABLED to disable. Default value is 50.

setWindowAlignmentPreferKeyLineOverHighEdge

Added in 1.0.0-alpha03
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

Added in 1.0.0-alpha03
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

Interpolator to be used for scrolling. If it is null, RecyclerView will use an internal default 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

Protected methods

dispatchGenericFocusedEvent

protected boolean dispatchGenericFocusedEvent(@NonNull MotionEvent event)

onFocusChanged

protected void onFocusChanged(
    boolean gainFocus,
    int direction,
    @Nullable Rect previouslyFocusedRect
)