java.lang.Object | ||||
↳ | android.view.View | |||
↳ | android.view.ViewGroup | |||
↳ | android.support.v7.widget.RecyclerView | |||
↳ | android.support.v17.leanback.widget.HorizontalGridView |
A ViewGroup
that shows items in a horizontal 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 HorizontalGridView. This facet also allows multiple
alignment positions within one ViewHolder.
[Expand]
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
getSaveChildrenLimitNumber() .
|
|||||||||
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. |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.support.v7.widget.RecyclerView
| |||||||||||
From class
android.view.ViewGroup
| |||||||||||
From class
android.view.View
|
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.view.View
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Dispatch a generic motion event to the currently focused view.
| |||||||||||
Dispatch a key event to the next view on the focus path.
| |||||||||||
Pass the touch screen motion event down to the target view, or this
view if it is the target.
| |||||||||||
Manually render this view (and all of its children) to the given Canvas.
| |||||||||||
Find the nearest view in the specified direction that can take focus.
| |||||||||||
Returns the index of the child to draw for this iteration.
| |||||||||||
Returns true if left edge fading is enabled.
| |||||||||||
Returns the left edge fading length in pixels.
| |||||||||||
Returns the distance in pixels between fading start position and left padding edge.
| |||||||||||
Returns true if fading right edge is enabled.
| |||||||||||
Returns the right edge fading length in pixels.
| |||||||||||
Sets the distance in pixels between fading start position and right padding edge.
| |||||||||||
Returns the strategy used to scroll in response to item focus changing.
| |||||||||||
Returns the margin in pixels between two child items horizontally.
| |||||||||||
Returns the absolute offset in pixels for item alignment.
| |||||||||||
Returns the offset percent for item alignment in addition to
getItemAlignmentOffset() .
| |||||||||||
Returns the id of the view to align with, or zero for the item view itself.
| |||||||||||
Returns the unhandled key listener.
| |||||||||||
Returns the limit used when when
getSaveChildrenPolicy() is
SAVE_LIMITED_CHILD
| |||||||||||
Returns the policy for saving children.
| |||||||||||
Returns the selected item position.
| |||||||||||
Returns the sub selected item position started from zero.
| |||||||||||
Returns the margin in pixels between two child items vertically.
| |||||||||||
Returns the x/y offsets to final position from current position if the view
is selected.
| |||||||||||
Returns the method for focused item alignment in the view.
| |||||||||||
Returns the offset in pixels for window alignment.
| |||||||||||
Returns the offset percent for window alignment in addition to
getWindowAlignmentOffset() .
| |||||||||||
Returns whether this View has content which overlaps.
| |||||||||||
Returns true if the view at the given position has a same row sibling
in front of it.
| |||||||||||
Returns true if an animation will run when a child changes size or when
adding or removing a child.
| |||||||||||
Returns true if default "focus draw at last" order rule is enabled.
| |||||||||||
Returns true if focus search is disabled.
| |||||||||||
Returns true if include padding in calculating item align offset.
| |||||||||||
Returns true if scrolling is enabled.
| |||||||||||
Look for a descendant to call
requestFocus() on.
| |||||||||||
Notify layout manager that layout directionality has been updated
| |||||||||||
Sets whether an animation should run when a child changes size or when adding
or removing a child.
| |||||||||||
Changes and overrides children's visibility.
| |||||||||||
Sets the fade out left edge to transparent.
| |||||||||||
Sets the left edge fading length in pixels.
| |||||||||||
Sets the distance in pixels between fading start position and left padding edge.
| |||||||||||
Sets the fade out right edge to transparent.
| |||||||||||
Sets the right edge fading length in pixels.
| |||||||||||
Returns the distance in pixels between fading start position and right padding edge.
| |||||||||||
Enables or disables the default "focus draw at last" order rule.
| |||||||||||
Sets the strategy used to scroll in response to item focus changing:
| |||||||||||
Disables or enables focus search.
| |||||||||||
Sets the gravity used for child view positioning.
| |||||||||||
Sets the margin in pixels between two child items horizontally.
| |||||||||||
Sets the absolute offset in pixels for item alignment.
| |||||||||||
Sets the offset percent for item alignment in addition to
getItemAlignmentOffset() .
| |||||||||||
Set to true if include padding in calculating item align offset.
| |||||||||||
Sets the id of the view to align with.
| |||||||||||
Sets the margin in pixels between two child items.
| |||||||||||
Enables or disables layout.
| |||||||||||
Sets the number of rows.
| |||||||||||
Registers a callback to be invoked when an item in BaseGridView has
been laid out.
| |||||||||||
Registers a callback to be invoked when an item in BaseGridView has
been selected.
| |||||||||||
Registers a callback to be invoked when an item in BaseGridView has
been selected.
| |||||||||||
Sets the key intercept listener.
| |||||||||||
Sets the generic motion intercept listener.
| |||||||||||
Sets the touch intercept listener.
| |||||||||||
Sets the unhandled key listener.
| |||||||||||
Enables or disables pruning of children.
| |||||||||||
Register a listener that will be notified whenever a child view is recycled.
| |||||||||||
Sets the row height.
| |||||||||||
Sets the limit number when
getSaveChildrenPolicy() is SAVE_LIMITED_CHILD .
| |||||||||||
Sets the policy for saving children.
| |||||||||||
Enables or disables scrolling.
| |||||||||||
Changes the selected item immediately without animation, scrollExtra is
applied in primary scroll direction.
| |||||||||||
Changes the selected item immediately without animation.
| |||||||||||
Changes the selected item and run an animation to scroll to the target
position.
| |||||||||||
Changes the selected item and/or subposition, runs an animation to scroll to the target
position.
| |||||||||||
Changes the selected item and/or subposition immediately without animation, scrollExtra is
applied in primary scroll direction.
| |||||||||||
Changes the selected item and/or subposition immediately without animation.
| |||||||||||
Sets the margin in pixels between two child items vertically.
| |||||||||||
Sets the method for focused item alignment in the view.
| |||||||||||
Sets the offset in pixels for window alignment.
| |||||||||||
Sets the offset percent for window alignment in addition to
getWindowAlignmentOffset() .
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Called by the view system when the focus state of this view changes.
|
[Expand]
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
|
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.
Scroll to make the focused item inside client area.
Scroll a page of items when focusing to item outside the client area. The page size matches the client area size of RecyclerView.
Value indicates that percent is not used.
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 on screen views plus save off screen child views states up to
getSaveChildrenLimitNumber()
.
Dont save states of any child views.
Only save on screen child views, the states are lost when they become off screen.
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.
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.
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.
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.
Value indicates that percent is not used.
Dispatch a generic motion event to the currently focused view.
Do not call this method directly.
Call dispatchGenericMotionEvent(MotionEvent)
instead.
event | The motion event to be dispatched. |
---|
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.
event | The key event to be dispatched. |
---|
Pass the touch screen motion event down to the target view, or this view if it is the target.
event | The motion event to be dispatched. |
---|
Manually render this view (and all of its children) to the given Canvas.
The view must have already done a full layout before this function is
called. When implementing a view, implement
onDraw(android.graphics.Canvas)
instead of overriding this method.
If you do need to override this method, call the superclass version.
canvas | The Canvas to which the View is rendered. |
---|
Find the nearest view in the specified direction that can take focus. This does not actually give focus to that view.
direction | One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and FOCUS_RIGHT |
---|
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)
.
i | The current iteration. |
---|
Returns true if left edge fading is enabled.
Returns the left edge fading length in pixels.
Returns the distance in pixels between fading start position and left padding edge. The fading start position is positive when start position is inside left padding area. Default value is 0, means that the fading starts from left padding edge.
Returns true if fading right edge is enabled.
Returns the right edge fading length in pixels.
Sets the distance in pixels between fading start position and right padding edge. The fading start position is positive when start position is inside right padding area. Default value is 0, means that the fading starts from right padding edge.
Returns the strategy used to scroll in response to item focus changing.
Returns the margin in pixels between two child items horizontally.
Returns the absolute offset in pixels for item alignment.
Returns the offset percent for item alignment in addition to getItemAlignmentOffset()
.
ITEM_ALIGN_OFFSET_PERCENT_DISABLED
if
disabled. Default value is 50.
Returns the id of the view to align with, or zero for the item view itself.
Returns the unhandled key listener.
Returns the limit used when when getSaveChildrenPolicy()
is
SAVE_LIMITED_CHILD
Returns the policy for saving children.
SAVE_NO_CHILD
SAVE_ON_SCREEN_CHILD
SAVE_LIMITED_CHILD
SAVE_ALL_CHILD
.
Returns the selected item position.
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 the margin in pixels between two child items vertically.
Returns the x/y offsets to final position from current position if the view is selected.
view | The view to get offsets. |
---|---|
offsets | offsets[0] holds offset of X, offsets[1] holds offset of Y. |
Returns the method for focused item alignment in the view.
Returns the offset in pixels for window alignment.
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.
Returns the offset percent for window alignment in addition to
getWindowAlignmentOffset()
.
WINDOW_ALIGN_OFFSET_PERCENT_DISABLED
if
disabled. Default value is 50.
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
.
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
.
position | Position in adapter. |
---|
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 true if default "focus draw at last" order rule is enabled.
Returns true if focus search is disabled.
Returns true if include padding in calculating item align offset.
Returns true if scrolling is enabled.
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.
direction | One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and FOCUS_RIGHT |
---|---|
previouslyFocusedRect | 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. |
Notify layout manager that layout directionality has been updated
layoutDirection | the direction of the layout |
---|
Sets whether an animation should run when a child changes size or when adding or removing a child.
Unstable API, might change later.
Changes and overrides children's visibility.
Sets the fade out left edge to transparent. Note turn on fading edge is very expensive that you should turn off when HorizontalGridView is scrolling.
Sets the left edge fading length in pixels.
Sets the distance in pixels between fading start position and left padding edge. The fading start position is positive when start position is inside left padding area. Default value is 0, means that the fading starts from left padding edge.
Sets the fade out right edge to transparent. Note turn on fading edge is very expensive that you should turn off when HorizontalGridView is scrolling.
Sets the right edge fading length in pixels.
Returns the distance in pixels between fading start position and right padding edge. The fading start position is positive when start position is inside right padding area. Default value is 0, means that the fading starts from right padding edge.
Enables or disables the default "focus draw at last" order rule.
Sets the strategy used to scroll in response to item focus changing:
Disables or enables focus search.
Sets the gravity used for child view positioning. Defaults to GRAVITY_TOP|GRAVITY_START.
gravity | See Gravity
|
---|
Sets the margin in pixels between two child items horizontally.
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
.
offset | The number of pixels to offset. Can be negative for alignment from the high edge, or positive for alignment from the low edge. |
---|
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
.
offsetPercent | Percentage to offset. E.g., 40 means 40% of the
width from the low edge. Use
ITEM_ALIGN_OFFSET_PERCENT_DISABLED to disable.
|
---|
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
.
withPadding | When it is true: we include left/top padding for positive item offset, include right/bottom padding for negative item offset. |
---|
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
.
Sets the margin in pixels between two child items.
Enables or disables layout. All children will be removed when layout is disabled.
Sets the number of rows. Defaults to one.
Registers a callback to be invoked when an item in BaseGridView has been laid out.
listener | The listener to be invoked. |
---|
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.
listener | The listener to be invoked. |
---|
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.
listener | The listener to be invoked. |
---|
Sets the key intercept listener.
Sets the generic motion intercept listener.
Sets the touch intercept listener.
Sets the unhandled key listener.
Enables or disables pruning of children. Disable is useful during transition.
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.
listener | Listener to register, or null to clear |
---|
Sets the row height.
height | May be WRAP_CONTENT ,
or a size in pixels. If zero, row height will be fixed based on number of
rows and view height.
|
---|
Sets the limit number when getSaveChildrenPolicy()
is SAVE_LIMITED_CHILD
.
Sets the policy for saving children.
savePolicy | One of SAVE_NO_CHILD SAVE_ON_SCREEN_CHILD
SAVE_LIMITED_CHILD SAVE_ALL_CHILD .
|
---|
Enables or disables scrolling. Disable is useful during transition.
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.
Changes the selected item immediately without animation.
Changes the selected item and run an animation to scroll to the target position.
Changes the selected item and/or subposition, runs an animation to scroll to the target position.
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.
Changes the selected item and/or subposition immediately without animation.
Sets the margin in pixels between two child items vertically.
Sets the method for focused item alignment in the view.
windowAlignment | WINDOW_ALIGN_BOTH_EDGE ,
WINDOW_ALIGN_LOW_EDGE , WINDOW_ALIGN_HIGH_EDGE or
WINDOW_ALIGN_NO_EDGE .
|
---|
Sets the offset in pixels for window alignment.
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.
|
---|
Sets the offset percent for window alignment in addition to getWindowAlignmentOffset()
.
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.
|
---|
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.
gainFocus | True if the View has focus; false otherwise. |
---|---|
direction | 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 | 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.
|