public
class
VerticalGridView
extends RecyclerView
java.lang.Object | ||||
↳ | android.view.View | |||
↳ | android.view.ViewGroup | |||
↳ | android.support.v7.widget.RecyclerView | |||
↳ | android.support.v17.leanback.widget.VerticalGridView |
A ViewGroup
that shows items in a vertically scrolling list. The items
come from the RecyclerView.Adapter
associated with this view.
RecyclerView.Adapter
can optionally implement FacetProviderAdapter
which
provides FacetProvider
for a given view type; RecyclerView.ViewHolder
can also implement FacetProvider
. Facet from ViewHolder
has a higher priority than the one from FacetProiderAdapter associated with viewType.
Supported optional facets are:
ItemAlignmentFacet
When this facet is provided by ViewHolder or FacetProviderAdapter, it will
override the item alignment settings set on VerticalGridView. This facet also allows multiple
alignment positions within one ViewHolder.
Inherited XML attributes | |
---|---|
From
class
android.support.v7.widget.RecyclerView
| |
From
class
android.view.ViewGroup
| |
From
class
android.view.View
|
Constants | |
---|---|
int |
FOCUS_SCROLL_ALIGNED
Always keep focused item at a aligned position. |
int |
FOCUS_SCROLL_ITEM
Scroll to make the focused item inside client area. |
int |
FOCUS_SCROLL_PAGE
Scroll a page of items when focusing to item outside the client area. |
float |
ITEM_ALIGN_OFFSET_PERCENT_DISABLED
Value indicates that percent is not used. |
int |
SAVE_ALL_CHILD
Save on screen views plus save off screen child views without any limitation. |
int |
SAVE_LIMITED_CHILD
Save on screen views plus save off screen child views states up to
|
int |
SAVE_NO_CHILD
Dont save states of any child views. |
int |
SAVE_ON_SCREEN_CHILD
Only save on screen child views, the states are lost when they become off screen. |
int |
WINDOW_ALIGN_BOTH_EDGE
The first item and last item are aligned with the two edges of the viewport. |
int |
WINDOW_ALIGN_HIGH_EDGE
The last item is aligned with the high edge of the viewport when navigating to the end of list. |
int |
WINDOW_ALIGN_LOW_EDGE
The first item is aligned with the low edge of the viewport. |
int |
WINDOW_ALIGN_NO_EDGE
The focused item always stays in a middle location. |
float |
WINDOW_ALIGN_OFFSET_PERCENT_DISABLED
Value indicates that percent is not used. |
Inherited constants |
---|
From
class
android.support.v7.widget.RecyclerView
|
From
class
android.view.ViewGroup
|
From
class
android.view.View
|
Inherited fields |
---|
From
class
android.view.View
|
Public constructors | |
---|---|
VerticalGridView(Context context)
|
|
VerticalGridView(Context context, AttributeSet attrs)
|
|
VerticalGridView(Context context, AttributeSet attrs, int defStyle)
|
Public methods | |
---|---|
void
|
addOnChildViewHolderSelectedListener(OnChildViewHolderSelectedListener listener)
Registers a callback to be invoked when an item in BaseGridView has been selected. |
boolean
|
dispatchGenericFocusedEvent(MotionEvent event)
Dispatch a generic motion event to the currently focused view. |
boolean
|
dispatchKeyEvent(KeyEvent event)
Dispatch a key event to the next view on the focus path. |
boolean
|
dispatchTouchEvent(MotionEvent event)
Pass the touch screen motion event down to the target view, or this view if it is the target. |
View
|
focusSearch(int direction)
Find the nearest view in the specified direction that can take focus. |
int
|
getChildDrawingOrder(int childCount, int i)
Returns the index of the child to draw for this iteration. |
int
|
getFocusScrollStrategy()
Returns the strategy used to scroll in response to item focus changing. |
int
|
getHorizontalMargin()
Returns the margin in pixels between two child items horizontally. |
int
|
getItemAlignmentOffset()
Returns the absolute offset in pixels for item alignment. |
float
|
getItemAlignmentOffsetPercent()
Returns the offset percent for item alignment in addition to |
int
|
getItemAlignmentViewId()
Returns the id of the view to align with, or zero for the item view itself. |
BaseGridView.OnUnhandledKeyListener
|
getOnUnhandledKeyListener()
Returns the unhandled key listener. |
final
int
|
getSaveChildrenLimitNumber()
Returns the limit used when when |
final
int
|
getSaveChildrenPolicy()
Returns the policy for saving children. |
int
|
getSelectedPosition()
Returns the selected item position. |
int
|
getSelectedSubPosition()
Returns the sub selected item position started from zero. |
int
|
getVerticalMargin()
Returns the margin in pixels between two child items vertically. |
void
|
getViewSelectedOffsets(View view, int[] offsets)
Returns the x/y offsets to final position from current position if the view is selected. |
int
|
getWindowAlignment()
Returns the method for focused item alignment in the view. |
int
|
getWindowAlignmentOffset()
Returns the offset in pixels for window alignment. |
float
|
getWindowAlignmentOffsetPercent()
Returns the offset percent for window alignment in addition to
|
boolean
|
hasOverlappingRendering()
Returns whether this View has content which overlaps. |
boolean
|
hasPreviousViewInSameRow(int position)
Returns true if the view at the given position has a same row sibling in front of it. |
boolean
|
isChildLayoutAnimated()
Returns true if an animation will run when a child changes size or when adding or removing a child. |
boolean
|
isFocusDrawingOrderEnabled()
Returns true if default "focus draw at last" order rule is enabled. |
final
boolean
|
isFocusSearchDisabled()
Returns true if focus search is disabled. |
boolean
|
isItemAlignmentOffsetWithPadding()
Returns true if include padding in calculating item align offset. |
boolean
|
isScrollEnabled()
Returns true if scrolling is enabled. |
boolean
|
onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect)
Look for a descendant to call |
void
|
onRtlPropertiesChanged(int layoutDirection)
Notify layout manager that layout directionality has been updated |
void
|
removeOnChildViewHolderSelectedListener(OnChildViewHolderSelectedListener listener)
Remove the callback invoked when an item in BaseGridView has been selected. |
void
|
setAnimateChildLayout(boolean animateChildLayout)
Sets whether an animation 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
|
setColumnWidth(int width)
Sets the column width. |
void
|
setFocusDrawingOrderEnabled(boolean enabled)
Enables or disables the default "focus draw at last" order rule. |
void
|
setFocusScrollStrategy(int scrollStrategy)
Sets the strategy used to scroll in response to item focus changing: |
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)
Sets the margin in pixels between two child items horizontally. |
void
|
setItemAlignmentOffset(int offset)
Sets the absolute offset in pixels for item alignment. |
void
|
setItemAlignmentOffsetPercent(float offsetPercent)
Sets the offset percent for item alignment in addition to |
void
|
setItemAlignmentOffsetWithPadding(boolean withPadding)
Set to true if include padding in calculating item align offset. |
void
|
setItemAlignmentViewId(int viewId)
Sets the id of the view to align with. |
void
|
setItemMargin(int margin)
Sets the margin in pixels between two child items. |
void
|
setLayoutEnabled(boolean layoutEnabled)
Enables or disables layout. |
void
|
setNumColumns(int numColumns)
Sets the number of columns. |
void
|
setOnChildLaidOutListener(OnChildLaidOutListener listener)
Registers a callback to be invoked when an item in BaseGridView has been laid out. |
void
|
setOnChildSelectedListener(OnChildSelectedListener listener)
Registers a callback to be invoked when an item in BaseGridView has been selected. |
void
|
setOnChildViewHolderSelectedListener(OnChildViewHolderSelectedListener listener)
Registers a callback to be invoked when an item in BaseGridView has been selected. |
void
|
setOnKeyInterceptListener(BaseGridView.OnKeyInterceptListener listener)
Sets the key intercept listener. |
void
|
setOnMotionInterceptListener(BaseGridView.OnMotionInterceptListener listener)
Sets the generic motion intercept listener. |
void
|
setOnTouchInterceptListener(BaseGridView.OnTouchInterceptListener listener)
Sets the touch intercept listener. |
void
|
setOnUnhandledKeyListener(BaseGridView.OnUnhandledKeyListener listener)
Sets the unhandled key listener. |
void
|
setPruneChild(boolean pruneChild)
Enables or disables pruning of children. |
void
|
setRecyclerListener(RecyclerView.RecyclerListener listener)
Register a listener that will be notified whenever a child view is recycled. |
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, ViewHolderTask task)
Perform a task on ViewHolder at given position after scroll to it. |
void
|
setSelectedPosition(int position, int scrollExtra)
Changes the selected item immediately without animation, scrollExtra is applied in primary scroll direction. |
void
|
setSelectedPosition(int position)
Changes the selected item immediately without animation. |
void
|
setSelectedPositionSmooth(int position)
Changes the selected item and run an animation to scroll to the target position. |
void
|
setSelectedPositionSmooth(int position, ViewHolderTask task)
Perform a task on ViewHolder at given position after smooth scrolling to it. |
void
|
setSelectedPositionSmoothWithSub(int position, int subposition)
Changes the selected item and/or subposition, runs an animation to scroll to the target position. |
void
|
setSelectedPositionWithSub(int position, int subposition)
Changes the selected item and/or subposition immediately without animation. |
void
|
setSelectedPositionWithSub(int position, int subposition, int scrollExtra)
Changes the selected item and/or subposition immediately without animation, scrollExtra is applied in primary scroll direction. |
void
|
setVerticalMargin(int margin)
Sets the margin in pixels between two child items vertically. |
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. |
void
|
setWindowAlignmentOffsetPercent(float offsetPercent)
Sets the offset percent for window alignment in addition to |
Protected methods | |
---|---|
void
|
initAttributes(Context context, AttributeSet attrs)
|
void
|
initBaseGridViewAttributes(Context context, AttributeSet attrs)
|
void
|
onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect)
Called by the view system when the focus state of this view changes. |
Inherited methods | |
---|---|
From
class
android.support.v7.widget.RecyclerView
| |
From
class
android.view.ViewGroup
| |
From
class
android.view.View
| |
From
class
java.lang.Object
| |
From
interface
android.support.v4.view.ScrollingView
| |
From
interface
android.support.v4.view.NestedScrollingChild
| |
From
interface
android.view.ViewParent
| |
From
interface
android.view.ViewManager
| |
From
interface
android.graphics.drawable.Drawable.Callback
| |
From
interface
android.view.KeyEvent.Callback
| |
From
interface
android.view.accessibility.AccessibilityEventSource
|
int FOCUS_SCROLL_ALIGNED
Always 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.
Constant Value: 0 (0x00000000)
int FOCUS_SCROLL_ITEM
Scroll to make the focused item inside client area.
Constant Value: 1 (0x00000001)
int FOCUS_SCROLL_PAGE
Scroll a page of items when focusing to item outside the client area. The page size matches the client area size of RecyclerView.
Constant Value: 2 (0x00000002)
float ITEM_ALIGN_OFFSET_PERCENT_DISABLED
Value indicates that percent is not used.
Constant Value: -1.0
int SAVE_ALL_CHILD
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.
Constant Value: 3 (0x00000003)
int SAVE_LIMITED_CHILD
Save on screen views plus save off screen child views states up to
getSaveChildrenLimitNumber()
.
Constant Value: 2 (0x00000002)
int SAVE_NO_CHILD
Dont save states of any child views.
Constant Value: 0 (0x00000000)
int SAVE_ON_SCREEN_CHILD
Only save on screen child views, the states are lost when they become off screen.
Constant Value: 1 (0x00000001)
int WINDOW_ALIGN_BOTH_EDGE
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 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.
Constant Value: 3 (0x00000003)
int WINDOW_ALIGN_HIGH_EDGE
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 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.
Constant Value: 2 (0x00000002)
int WINDOW_ALIGN_LOW_EDGE
The 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.
Constant Value: 1 (0x00000001)
int WINDOW_ALIGN_NO_EDGE
The 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.
Constant Value: 0 (0x00000000)
float WINDOW_ALIGN_OFFSET_PERCENT_DISABLED
Value indicates that percent is not used.
Constant Value: -1.0
VerticalGridView (Context context, AttributeSet attrs)
Parameters | |
---|---|
context |
Context
|
attrs |
AttributeSet
|
VerticalGridView (Context context, AttributeSet attrs, int defStyle)
Parameters | |
---|---|
context |
Context
|
attrs |
AttributeSet
|
defStyle |
int
|
void addOnChildViewHolderSelectedListener (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 | |
---|---|
listener |
OnChildViewHolderSelectedListener :
The listener to be invoked.
|
boolean dispatchGenericFocusedEvent (MotionEvent event)
Dispatch a generic motion event to the currently focused view.
Do not call this method directly.
Call dispatchGenericMotionEvent(MotionEvent)
instead.
Parameters | |
---|---|
event |
MotionEvent :
The motion event to be dispatched. |
Returns | |
---|---|
boolean |
True if the event was handled by the view, false otherwise. |
boolean dispatchKeyEvent (KeyEvent event)
Dispatch a key event to the next view on the focus path. This path runs from the top of the view tree down to the currently focused view. If this view has focus, it will dispatch to itself. Otherwise it will dispatch the next node down the focus path. This method also fires any key listeners.
Parameters | |
---|---|
event |
KeyEvent :
The key event to be dispatched. |
Returns | |
---|---|
boolean |
True if the event was handled, false otherwise. |
boolean dispatchTouchEvent (MotionEvent event)
Pass the touch screen motion event down to the target view, or this view if it is the target.
Parameters | |
---|---|
event |
MotionEvent :
The motion event to be dispatched. |
Returns | |
---|---|
boolean |
True if the event was handled by the view, false otherwise. |
View focusSearch (int direction)
Find the nearest view in the specified direction that can take focus. This does not actually give focus to that view.
Parameters | |
---|---|
direction |
int :
One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and FOCUS_RIGHT |
Returns | |
---|---|
View |
The nearest focusable in the specified direction, or null if none can be found. |
int getChildDrawingOrder (int childCount, int i)
Returns the index of the child to draw for this iteration. Override this if you want to change the drawing order of children. By default, it returns i.
NOTE: In order for this method to be called, you must enable child ordering
first by calling setChildrenDrawingOrderEnabled(boolean)
.
Parameters | |
---|---|
childCount |
int
|
i |
int :
The current iteration. |
Returns | |
---|---|
int |
The index of the child to draw this iteration. |
int getFocusScrollStrategy ()
Returns the strategy used to scroll in response to item focus changing.
Returns | |
---|---|
int |
int getHorizontalMargin ()
Returns the margin in pixels between two child items horizontally.
Returns | |
---|---|
int |
int getItemAlignmentOffset ()
Returns the absolute offset in pixels for item alignment.
Returns | |
---|---|
int |
The number of pixels to offset. Will be negative for alignment from the high edge, or positive for alignment from the low edge. Default value is 0. |
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.
|
int getItemAlignmentViewId ()
Returns the id of the view to align with, or zero for the item view itself.
Returns | |
---|---|
int |
BaseGridView.OnUnhandledKeyListener getOnUnhandledKeyListener ()
Returns the unhandled key listener.
Returns | |
---|---|
BaseGridView.OnUnhandledKeyListener |
int getSaveChildrenLimitNumber ()
Returns the limit used when when getSaveChildrenPolicy()
is
SAVE_LIMITED_CHILD
Returns | |
---|---|
int |
int getSaveChildrenPolicy ()
Returns the policy for saving children.
Returns | |
---|---|
int |
policy, one of SAVE_NO_CHILD
SAVE_ON_SCREEN_CHILD SAVE_LIMITED_CHILD SAVE_ALL_CHILD .
|
int getSelectedPosition ()
Returns the selected item position.
Returns | |
---|---|
int |
int getSelectedSubPosition ()
Returns the sub selected item position started from zero. An item can have
multiple ItemAlignmentFacet
s provided by RecyclerView.ViewHolder
or FacetProviderAdapter
. Zero is returned when no ItemAlignmentFacet
is defined.
Returns | |
---|---|
int |
int getVerticalMargin ()
Returns the margin in pixels between two child items vertically.
Returns | |
---|---|
int |
void getViewSelectedOffsets (View view, int[] offsets)
Returns the x/y offsets to final position from current position if the view is selected.
Parameters | |
---|---|
view |
View :
The view to get offsets. |
offsets |
int :
offsets[0] holds offset of X, offsets[1] holds offset of Y.
|
int getWindowAlignment ()
Returns the method for focused item alignment in the view.
Returns | |
---|---|
int |
WINDOW_ALIGN_BOTH_EDGE , WINDOW_ALIGN_LOW_EDGE ,
WINDOW_ALIGN_HIGH_EDGE or WINDOW_ALIGN_NO_EDGE .
|
int getWindowAlignmentOffset ()
Returns the offset in pixels for window alignment.
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.
|
float getWindowAlignmentOffsetPercent ()
Returns the offset percent for window alignment 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.
|
boolean hasOverlappingRendering ()
Returns whether this View has content which overlaps.
This function, intended to be overridden by specific View types, is an optimization when alpha is set on a view. If rendering overlaps in a view with alpha < 1, that view is drawn to an offscreen buffer and then composited into place, which can be expensive. If the view has no overlapping rendering, the view can draw each primitive with the appropriate alpha value directly. An example of overlapping rendering is a TextView with a background image, such as a Button. An example of non-overlapping rendering is a TextView with no background, or an ImageView with only the foreground image. The default implementation returns true; subclasses should override if they have cases which can be optimized.
The current implementation of the saveLayer and saveLayerAlpha methods in Canvas
necessitates that a View return true if it uses the methods internally without passing the
CLIP_TO_LAYER_SAVE_FLAG
.
Note: The return value of this method is ignored if forceHasOverlappingRendering(boolean)
has been called on this view.
Returns | |
---|---|
boolean |
true if the content in this view might overlap, false otherwise. |
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.
So application should check in both OnChildSelectedListener
and OnChildLaidOutListener
.
Parameters | |
---|---|
position |
int :
Position in adapter.
|
Returns | |
---|---|
boolean |
boolean isChildLayoutAnimated ()
Returns true if an animation will run when a child changes size or when adding or removing a child.
Unstable API, might change later.
Returns | |
---|---|
boolean |
boolean isFocusDrawingOrderEnabled ()
Returns true if default "focus draw at last" order rule is enabled.
Returns | |
---|---|
boolean |
boolean isFocusSearchDisabled ()
Returns true if focus search is disabled.
Returns | |
---|---|
boolean |
boolean isItemAlignmentOffsetWithPadding ()
Returns true if include padding in calculating item align offset.
Returns | |
---|---|
boolean |
boolean isScrollEnabled ()
Returns true if scrolling is enabled.
Returns | |
---|---|
boolean |
boolean onRequestFocusInDescendants (int direction, Rect previouslyFocusedRect)
Look for a descendant to call requestFocus()
on.
Called by requestFocus(int, android.graphics.Rect)
when it wants to request focus within its children. Override this to
customize how your ViewGroup
requests focus within its children.
Parameters | |
---|---|
direction |
int :
One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and FOCUS_RIGHT |
previouslyFocusedRect |
Rect :
The rectangle (in this View's coordinate system)
to give a finer grained hint about where focus is coming from. May be null
if there is no hint. |
Returns | |
---|---|
boolean |
Whether focus was taken. |
void onRtlPropertiesChanged (int layoutDirection)
Notify layout manager that layout directionality has been updated
Parameters | |
---|---|
layoutDirection |
int :
the direction of the layout |
void removeOnChildViewHolderSelectedListener (OnChildViewHolderSelectedListener listener)
Remove the callback invoked when an item in BaseGridView has been selected.
Parameters | |
---|---|
listener |
OnChildViewHolderSelectedListener :
The listener to be removed.
|
void setAnimateChildLayout (boolean animateChildLayout)
Sets whether an animation should run when a child changes size or when adding or removing a child.
Unstable API, might change later.
Parameters | |
---|---|
animateChildLayout |
boolean
|
void setChildrenVisibility (int visibility)
Changes and overrides children's visibility.
Parameters | |
---|---|
visibility |
int
|
void setColumnWidth (int width)
Sets the column width.
Parameters | |
---|---|
width |
int :
May be WRAP_CONTENT , or a size
in pixels. If zero, column width will be fixed based on number of columns
and view width.
|
void setFocusDrawingOrderEnabled (boolean enabled)
Enables or disables the default "focus draw at last" order rule.
Parameters | |
---|---|
enabled |
boolean
|
void setFocusScrollStrategy (int scrollStrategy)
Sets the strategy used to scroll in response to item focus changing:
Parameters | |
---|---|
scrollStrategy |
int
|
void setFocusSearchDisabled (boolean disabled)
Disables or enables focus search.
Parameters | |
---|---|
disabled |
boolean
|
void setGravity (int gravity)
Sets the gravity used for child view positioning. Defaults to GRAVITY_TOP|GRAVITY_START.
Parameters | |
---|---|
gravity |
int :
See Gravity
|
void setHasOverlappingRendering (boolean hasOverlapping)
Parameters | |
---|---|
hasOverlapping |
boolean
|
void setHorizontalMargin (int margin)
Sets the margin in pixels between two child items horizontally.
Parameters | |
---|---|
margin |
int
|
void setItemAlignmentOffset (int offset)
Sets the absolute offset in pixels for item alignment.
Item alignment settings are ignored for the child if ItemAlignmentFacet
is provided by RecyclerView.ViewHolder
or FacetProviderAdapter
.
Parameters | |
---|---|
offset |
int :
The number of pixels to offset. Can be negative for
alignment from the high edge, or positive for alignment from the
low edge.
|
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 | |
---|---|
offsetPercent |
float :
Percentage to offset. E.g., 40 means 40% of the
width from the low edge. Use
ITEM_ALIGN_OFFSET_PERCENT_DISABLED to disable.
|
void setItemAlignmentOffsetWithPadding (boolean withPadding)
Set to true if include padding in calculating item align offset.
Item alignment settings are ignored for the child if ItemAlignmentFacet
is provided by RecyclerView.ViewHolder
or FacetProviderAdapter
.
Parameters | |
---|---|
withPadding |
boolean :
When it is true: we include left/top padding for positive
item offset, include right/bottom padding for negative item offset.
|
void setItemAlignmentViewId (int viewId)
Sets the id of the view to align with. Use NO_ID
(default)
for the item view itself.
Item alignment settings are ignored for the child if ItemAlignmentFacet
is provided by RecyclerView.ViewHolder
or FacetProviderAdapter
.
Parameters | |
---|---|
viewId |
int
|
void setItemMargin (int margin)
Sets the margin in pixels between two child items.
Parameters | |
---|---|
margin |
int
|
void setLayoutEnabled (boolean layoutEnabled)
Enables or disables layout. All children will be removed when layout is disabled.
Parameters | |
---|---|
layoutEnabled |
boolean
|
void setNumColumns (int numColumns)
Sets the number of columns. Defaults to one.
Parameters | |
---|---|
numColumns |
int
|
void setOnChildLaidOutListener (OnChildLaidOutListener listener)
Registers a callback to be invoked when an item in BaseGridView has been laid out.
Parameters | |
---|---|
listener |
OnChildLaidOutListener :
The listener to be invoked.
|
void setOnChildSelectedListener (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 | |
---|---|
listener |
OnChildSelectedListener :
The listener to be invoked.
|
void setOnChildViewHolderSelectedListener (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(OnChildViewHolderSelectedListener)
.
Parameters | |
---|---|
listener |
OnChildViewHolderSelectedListener :
The listener to be invoked.
|
void setOnKeyInterceptListener (BaseGridView.OnKeyInterceptListener listener)
Sets the key intercept listener.
Parameters | |
---|---|
listener |
BaseGridView.OnKeyInterceptListener
|
void setOnMotionInterceptListener (BaseGridView.OnMotionInterceptListener listener)
Sets the generic motion intercept listener.
Parameters | |
---|---|
listener |
BaseGridView.OnMotionInterceptListener
|
void setOnTouchInterceptListener (BaseGridView.OnTouchInterceptListener listener)
Sets the touch intercept listener.
Parameters | |
---|---|
listener |
BaseGridView.OnTouchInterceptListener
|
void setOnUnhandledKeyListener (BaseGridView.OnUnhandledKeyListener listener)
Sets the unhandled key listener.
Parameters | |
---|---|
listener |
BaseGridView.OnUnhandledKeyListener
|
void setPruneChild (boolean pruneChild)
Enables or disables pruning of children. Disable is useful during transition.
Parameters | |
---|---|
pruneChild |
boolean
|
void setRecyclerListener (RecyclerView.RecyclerListener listener)
Register a listener that will be notified whenever a child view is recycled.
This listener will be called when a LayoutManager or the RecyclerView decides that a child view is no longer needed. If an application associates expensive or heavyweight data with item views, this may be a good place to release or free those resources.
Parameters | |
---|---|
listener |
RecyclerView.RecyclerListener :
Listener to register, or null to clear
|
void setSaveChildrenLimitNumber (int limitNumber)
Sets the limit number when getSaveChildrenPolicy()
is SAVE_LIMITED_CHILD
.
Parameters | |
---|---|
limitNumber |
int
|
void setSaveChildrenPolicy (int savePolicy)
Sets the policy for saving children.
Parameters | |
---|---|
savePolicy |
int :
One of SAVE_NO_CHILD SAVE_ON_SCREEN_CHILD
SAVE_LIMITED_CHILD SAVE_ALL_CHILD .
|
void setScrollEnabled (boolean scrollEnabled)
Enables or disables scrolling. Disable is useful during transition.
Parameters | |
---|---|
scrollEnabled |
boolean
|
void setSelectedPosition (int position, ViewHolderTask task)
Perform a task on ViewHolder at given position after scroll to it.
Parameters | |
---|---|
position |
int :
Position of item in adapter. |
task |
ViewHolderTask :
Task to executed on the ViewHolder at a given position.
|
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(int)
or setSelectedPositionSmooth(int)
call.
Parameters | |
---|---|
position |
int
|
scrollExtra |
int
|
void setSelectedPosition (int position)
Changes the selected item immediately without animation.
Parameters | |
---|---|
position |
int
|
void setSelectedPositionSmooth (int position)
Changes the selected item and run an animation to scroll to the target position.
Parameters | |
---|---|
position |
int
|
void setSelectedPositionSmooth (int position, ViewHolderTask task)
Perform a task on ViewHolder at given position after smooth scrolling to it.
Parameters | |
---|---|
position |
int :
Position of item in adapter. |
task |
ViewHolderTask :
Task to executed on the ViewHolder at a given position.
|
void setSelectedPositionSmoothWithSub (int position, int subposition)
Changes the selected item and/or subposition, runs an animation to scroll to the target position.
Parameters | |
---|---|
position |
int
|
subposition |
int
|
void setSelectedPositionWithSub (int position, int subposition)
Changes the selected item and/or subposition immediately without animation.
Parameters | |
---|---|
position |
int
|
subposition |
int
|
void setSelectedPositionWithSub (int position, int subposition, int scrollExtra)
Changes the selected item and/or subposition immediately without animation, scrollExtra is
applied in primary scroll direction. The scrollExtra will be kept until
another setSelectedPosition(int)
or setSelectedPositionSmooth(int)
call.
Parameters | |
---|---|
position |
int
|
subposition |
int
|
scrollExtra |
int
|
void setVerticalMargin (int margin)
Sets the margin in pixels between two child items vertically.
Parameters | |
---|---|
margin |
int
|
void setWindowAlignment (int windowAlignment)
Sets the method for focused item alignment in the view.
Parameters | |
---|---|
windowAlignment |
int :
WINDOW_ALIGN_BOTH_EDGE ,
WINDOW_ALIGN_LOW_EDGE , WINDOW_ALIGN_HIGH_EDGE or
WINDOW_ALIGN_NO_EDGE .
|
void setWindowAlignmentOffset (int offset)
Sets the offset in pixels for window alignment.
Parameters | |
---|---|
offset |
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.
|
void setWindowAlignmentOffsetPercent (float offsetPercent)
Sets the offset percent for window alignment in addition to getWindowAlignmentOffset()
.
Parameters | |
---|---|
offsetPercent |
float :
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.
|
void initAttributes (Context context, AttributeSet attrs)
Parameters | |
---|---|
context |
Context
|
attrs |
AttributeSet
|
void initBaseGridViewAttributes (Context context, AttributeSet attrs)
Parameters | |
---|---|
context |
Context
|
attrs |
AttributeSet
|
void onFocusChanged (boolean gainFocus, int direction, Rect previouslyFocusedRect)
Called by the view system when the focus state of this view changes. When the focus change event is caused by directional navigation, direction and previouslyFocusedRect provide insight into where the focus is coming from. When overriding, be sure to call up through to the super class so that the standard focus handling will occur.
Parameters | |
---|---|
gainFocus |
boolean :
True if the View has focus; false otherwise. |
direction |
int :
The direction focus has moved when requestFocus()
is called to give this view focus. Values are
FOCUS_UP , FOCUS_DOWN , FOCUS_LEFT ,
FOCUS_RIGHT , FOCUS_FORWARD , or FOCUS_BACKWARD .
It may not always apply, in which case use the default. |
previouslyFocusedRect |
Rect :
The rectangle, in this view's coordinate
system, of the previously focused view. If applicable, this will be
passed in as finer grained information about where the focus is coming
from (in addition to direction). Will be null otherwise.
|