Fields Summary |
---|
public static final int | FOCUS_SCROLL_ALIGNEDAlways keep focused item at a aligned position. Developer can use
WINDOW_ALIGN_XXX and ITEM_ALIGN_XXX to define how focused item is aligned.
In this mode, the last focused position will be remembered and restored when focus
is back to the view. |
public static final int | FOCUS_SCROLL_ITEMScroll to make the focused item inside client area. |
public static final int | FOCUS_SCROLL_PAGEScroll a page of items when focusing to item outside the client area.
The page size matches the client area size of RecyclerView. |
public static final int | WINDOW_ALIGN_LOW_EDGEThe first item is aligned with the low edge of the viewport. When
navigating away from the first item, the focus maintains a middle
location.
For HorizontalGridView, low edge refers to left edge when RTL is false or
right edge when RTL is true.
For VerticalGridView, low edge refers to top edge.
The middle location is calculated by "windowAlignOffset" and
"windowAlignOffsetPercent"; if neither of these two is defined, the
default value is 1/2 of the size. |
public static final int | WINDOW_ALIGN_HIGH_EDGEThe 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 maintains a middle location.
For HorizontalGridView, high edge refers to right edge when RTL is false or
left edge when RTL is true.
For VerticalGridView, high edge refers to bottom edge.
The middle location is calculated by "windowAlignOffset" and
"windowAlignOffsetPercent"; if neither of these two is defined, the
default value is 1/2 of the size. |
public static final int | WINDOW_ALIGN_BOTH_EDGEThe 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
middle location.
The middle location is calculated by "windowAlignOffset" and
"windowAlignOffsetPercent"; if neither of these two is defined, the
default value is 1/2 of the size. |
public static final int | WINDOW_ALIGN_NO_EDGEThe focused item always stays in a middle location.
The middle location is calculated by "windowAlignOffset" and
"windowAlignOffsetPercent"; if neither of these two is defined, the
default value is 1/2 of the size. |
public static final float | WINDOW_ALIGN_OFFSET_PERCENT_DISABLEDValue indicates that percent is not used. |
public static final float | ITEM_ALIGN_OFFSET_PERCENT_DISABLEDValue indicates that percent is not used. |
public static final int | SAVE_NO_CHILDDont save states of any child views. |
public static final int | SAVE_ON_SCREEN_CHILDOnly save on screen child views, the states are lost when they become off screen. |
public static final int | SAVE_LIMITED_CHILDSave on screen views plus save off screen child views states up to
{@link #getSaveChildrenLimitNumber()}. |
public static final int | SAVE_ALL_CHILDSave 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. |
protected final GridLayoutManager | mLayoutManager |
private boolean | mAnimateChildLayoutAnimate layout changes from a child resizing or adding/removing a child. |
private boolean | mHasOverlappingRendering |
private RecyclerView.ItemAnimator | mSavedItemAnimator |
private OnTouchInterceptListener | mOnTouchInterceptListener |
private OnMotionInterceptListener | mOnMotionInterceptListener |
private OnKeyInterceptListener | mOnKeyInterceptListener |
Methods Summary |
---|
public boolean | dispatchGenericFocusedEvent(android.view.MotionEvent event)
if (mOnMotionInterceptListener != null) {
if (mOnMotionInterceptListener.onInterceptMotionEvent(event)) {
return true;
}
}
return super.dispatchGenericFocusedEvent(event);
|
public boolean | dispatchKeyEvent(android.view.KeyEvent event)
if (mOnKeyInterceptListener != null) {
if (mOnKeyInterceptListener.onInterceptKeyEvent(event)) {
return true;
}
}
return super.dispatchKeyEvent(event);
|
public boolean | dispatchTouchEvent(android.view.MotionEvent event)
if (mOnTouchInterceptListener != null) {
if (mOnTouchInterceptListener.onInterceptTouchEvent(event)) {
return true;
}
}
return super.dispatchTouchEvent(event);
|
public int | getChildDrawingOrder(int childCount, int i)
return mLayoutManager.getChildDrawingOrder(this, childCount, i);
|
public int | getFocusScrollStrategy()Returns the strategy used to scroll in response to item focus changing.
- {@link #FOCUS_SCROLL_ALIGNED} (default)
- {@link #FOCUS_SCROLL_ITEM}
- {@link #FOCUS_SCROLL_PAGE}
return mLayoutManager.getFocusScrollStrategy();
|
public int | getHorizontalMargin()Get the margin in pixels between two child items horizontally.
return mLayoutManager.getHorizontalMargin();
|
public int | getItemAlignmentOffset()Get the absolute offset in pixels for item alignment.
return mLayoutManager.getItemAlignmentOffset();
|
public float | getItemAlignmentOffsetPercent()Get offset percent for item alignment in addition to {@link
#getItemAlignmentOffset()}.
return mLayoutManager.getItemAlignmentOffsetPercent();
|
public int | getItemAlignmentViewId()Get the id of the view to align with, or zero for the item view itself.
return mLayoutManager.getItemAlignmentViewId();
|
public final int | getSaveChildrenLimitNumber()
return mLayoutManager.mChildrenStates.getLimitNumber();
|
public final int | getSaveChildrenPolicy()
return mLayoutManager.mChildrenStates.getSavePolicy();
|
public int | getSelectedPosition()Get the selected item position.
return mLayoutManager.getSelection();
|
public int | getVerticalMargin()Get the margin in pixels between two child items vertically.
return mLayoutManager.getVerticalMargin();
|
public void | getViewSelectedOffsets(android.view.View view, int[] offsets)Get the x/y offsets to final position from current position if the view
is selected.
mLayoutManager.getViewSelectedOffsets(view, offsets);
|
public int | getWindowAlignment()Get how the focused item gets aligned in the view.
return mLayoutManager.getWindowAlignment();
|
public int | getWindowAlignmentOffset()Get the offset in pixels for window alignment.
return mLayoutManager.getWindowAlignmentOffset();
|
public float | getWindowAlignmentOffsetPercent()Get offset percent for window alignment in addition to
{@link #getWindowAlignmentOffset()}.
return mLayoutManager.getWindowAlignmentOffsetPercent();
|
public boolean | hasOverlappingRendering()
return mHasOverlappingRendering;
|
public boolean | hasPreviousViewInSameRow(int position)Returns true if the view at the given position has a same row sibling
in front of it.
return mLayoutManager.hasPreviousViewInSameRow(position);
|
protected void | initBaseGridViewAttributes(android.content.Context context, android.util.AttributeSet attrs)
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.lbBaseGridView);
boolean throughFront = a.getBoolean(R.styleable.lbBaseGridView_focusOutFront, false);
boolean throughEnd = a.getBoolean(R.styleable.lbBaseGridView_focusOutEnd, false);
mLayoutManager.setFocusOutAllowed(throughFront, throughEnd);
mLayoutManager.setVerticalMargin(
a.getDimensionPixelSize(R.styleable.lbBaseGridView_verticalMargin, 0));
mLayoutManager.setHorizontalMargin(
a.getDimensionPixelSize(R.styleable.lbBaseGridView_horizontalMargin, 0));
if (a.hasValue(R.styleable.lbBaseGridView_android_gravity)) {
setGravity(a.getInt(R.styleable.lbBaseGridView_android_gravity, Gravity.NO_GRAVITY));
}
a.recycle();
|
public boolean | isChildLayoutAnimated()Return true if an animation will run when a child changes size or when
adding or removing a child.
Unstable API, might change later.
return mAnimateChildLayout;
|
final boolean | isChildrenDrawingOrderEnabledInternal()
return isChildrenDrawingOrderEnabled();
|
public boolean | isFocusDrawingOrderEnabled()Returns true if default "focus draw at last" order rule is enabled.
return super.isChildrenDrawingOrderEnabled();
|
public final boolean | isFocusSearchDisabled()Return true if focus search is disabled.
return mLayoutManager.isFocusSearchDisabled();
|
public boolean | isItemAlignmentOffsetWithPadding()Returns true if include padding in calculating item align offset.
return mLayoutManager.isItemAlignmentOffsetWithPadding();
|
public boolean | isScrollEnabled()Returns true if scrolling is enabled.
return mLayoutManager.isScrollEnabled();
|
public boolean | onRequestFocusInDescendants(int direction, android.graphics.Rect previouslyFocusedRect)
return mLayoutManager.gridOnRequestFocusInDescendants(this, direction,
previouslyFocusedRect);
|
public void | onRtlPropertiesChanged(int layoutDirection)Notify layout manager that layout directionality has been updated
mLayoutManager.onRtlPropertiesChanged(layoutDirection);
|
public void | setAnimateChildLayout(boolean animateChildLayout)Set if an animation should run when a child changes size or when adding
or removing a child.
Unstable API, might change later.
if (mAnimateChildLayout != animateChildLayout) {
mAnimateChildLayout = animateChildLayout;
if (!mAnimateChildLayout) {
mSavedItemAnimator = getItemAnimator();
super.setItemAnimator(null);
} else {
super.setItemAnimator(mSavedItemAnimator);
}
}
|
public void | setChildrenVisibility(int visibility)Change and override children's visibility.
mLayoutManager.setChildrenVisibility(visibility);
|
public void | setFocusDrawingOrderEnabled(boolean enabled)Enable or disable the default "focus draw at last" order rule.
super.setChildrenDrawingOrderEnabled(enabled);
|
public void | setFocusScrollStrategy(int scrollStrategy)Set the strategy used to scroll in response to item focus changing:
- {@link #FOCUS_SCROLL_ALIGNED} (default)
- {@link #FOCUS_SCROLL_ITEM}
- {@link #FOCUS_SCROLL_PAGE}
if (scrollStrategy != FOCUS_SCROLL_ALIGNED && scrollStrategy != FOCUS_SCROLL_ITEM
&& scrollStrategy != FOCUS_SCROLL_PAGE) {
throw new IllegalArgumentException("Invalid scrollStrategy");
}
mLayoutManager.setFocusScrollStrategy(scrollStrategy);
requestLayout();
|
public final void | setFocusSearchDisabled(boolean disabled)Disable or enable focus search.
mLayoutManager.setFocusSearchDisabled(disabled);
|
public void | setGravity(int gravity)Describes how the child views are positioned. Defaults to
GRAVITY_TOP|GRAVITY_START.
mLayoutManager.setGravity(gravity);
requestLayout();
|
public void | setHasOverlappingRendering(boolean hasOverlapping)
mHasOverlappingRendering = hasOverlapping;
|
public void | setHorizontalMargin(int margin)Set the margin in pixels between two child items horizontally.
mLayoutManager.setHorizontalMargin(margin);
requestLayout();
|
public void | setItemAlignmentOffset(int offset)Set the absolute offset in pixels for item alignment.
mLayoutManager.setItemAlignmentOffset(offset);
requestLayout();
|
public void | setItemAlignmentOffsetPercent(float offsetPercent)Set offset percent for item alignment in addition to {@link
#getItemAlignmentOffset()}.
mLayoutManager.setItemAlignmentOffsetPercent(offsetPercent);
requestLayout();
|
public void | setItemAlignmentOffsetWithPadding(boolean withPadding)Set to true if include padding in calculating item align offset.
mLayoutManager.setItemAlignmentOffsetWithPadding(withPadding);
requestLayout();
|
public void | setItemAlignmentViewId(int viewId)Set the id of the view to align with. Use zero (default) for the item
view itself.
mLayoutManager.setItemAlignmentViewId(viewId);
|
public void | setItemMargin(int margin)Set the margin in pixels between two child items.
mLayoutManager.setItemMargin(margin);
requestLayout();
|
public void | setLayoutEnabled(boolean layoutEnabled)Enable or disable layout. All children will be removed when layout is
disabled.
mLayoutManager.setLayoutEnabled(layoutEnabled);
|
public void | setOnChildSelectedListener(OnChildSelectedListener listener)Register 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.
mLayoutManager.setOnChildSelectedListener(listener);
|
public void | setOnKeyInterceptListener(android.support.v17.leanback.widget.BaseGridView$OnKeyInterceptListener listener)Sets the key intercept listener.
mOnKeyInterceptListener = listener;
|
public void | setOnMotionInterceptListener(android.support.v17.leanback.widget.BaseGridView$OnMotionInterceptListener listener)Sets the generic motion intercept listener.
mOnMotionInterceptListener = listener;
|
public void | setOnTouchInterceptListener(android.support.v17.leanback.widget.BaseGridView$OnTouchInterceptListener listener)Sets the touch intercept listener.
mOnTouchInterceptListener = listener;
|
public void | setPruneChild(boolean pruneChild)Enable or disable pruning child. Disable is useful during transition.
mLayoutManager.setPruneChild(pruneChild);
|
public final void | setSaveChildrenLimitNumber(int limitNumber)Set limit number when {@link #getSaveChildrenPolicy()} is {@link #SAVE_LIMITED_CHILD}.
mLayoutManager.mChildrenStates.setLimitNumber(limitNumber);
|
public final void | setSaveChildrenPolicy(int savePolicy)Set policy for saving children.
mLayoutManager.mChildrenStates.setSavePolicy(savePolicy);
|
public void | setScrollEnabled(boolean scrollEnabled)Enable or disable scrolling. Disable is useful during transition.
mLayoutManager.setScrollEnabled(scrollEnabled);
|
public void | setSelectedPosition(int position)Change the selected item immediately without animation.
mLayoutManager.setSelection(this, position);
|
public void | setSelectedPositionSmooth(int position)Change the selected item and run an animation to scroll to the target
position.
mLayoutManager.setSelectionSmooth(this, position);
|
public void | setVerticalMargin(int margin)Set the margin in pixels between two child items vertically.
mLayoutManager.setVerticalMargin(margin);
requestLayout();
|
public void | setWindowAlignment(int windowAlignment)Set how the focused item gets aligned in the view.
mLayoutManager.setWindowAlignment(windowAlignment);
requestLayout();
|
public void | setWindowAlignmentOffset(int offset)Set the offset in pixels for window alignment.
mLayoutManager.setWindowAlignmentOffset(offset);
requestLayout();
|
public void | setWindowAlignmentOffsetPercent(float offsetPercent)Set offset percent for window alignment in addition to {@link
#getWindowAlignmentOffset()}.
mLayoutManager.setWindowAlignmentOffsetPercent(offsetPercent);
requestLayout();
|