FocusFinder
public
class
FocusFinder
extends Object
| java.lang.Object | |
| ↳ | android.view.FocusFinder |
The algorithm used for finding the next focusable view in a given direction from a view that currently has focus.
Summary
Public methods | |
|---|---|
View
|
findNearestTouchable(ViewGroup root, int x, int y, int direction, int[] deltas)
Find the nearest touchable view to the specified view. |
final
View
|
findNextFocus(ViewGroup root, View focused, int direction)
Find the next view to take focus in root's descendants, starting from the view that currently is focused. |
View
|
findNextFocusFromRect(ViewGroup root, Rect focusedRect, int direction)
Find the next view to take focus in root's descendants, searching from a particular rectangle in root's coordinates. |
View
|
findNextKeyboardNavigationCluster(View root, View currentCluster, int direction)
Find the root of the next keyboard navigation cluster after the current one. |
static
FocusFinder
|
getInstance()
Get the focus finder for this thread. |
Inherited methods | |
|---|---|
Public methods
findNearestTouchable
public View findNearestTouchable (ViewGroup root, int x, int y, int direction, int[] deltas)
Find the nearest touchable view to the specified view.
| Parameters | |
|---|---|
root |
ViewGroup: The root of the tree in which to search |
x |
int: X coordinate from which to start the search |
y |
int: Y coordinate from which to start the search |
direction |
int: Direction to look |
deltas |
int: Offset from the |
| Returns | |
|---|---|
View |
The nearest touchable view, or null if none exists. |
findNextFocus
public final View findNextFocus (ViewGroup root, View focused, int direction)
Find the next view to take focus in root's descendants, starting from the view that currently is focused.
If focused is not part of the active focusable sequence (for example, if it is
an accessibility focus node that is not capable of taking input focus), this method falls
back to a generic entry behavior for relative focus navigation (View.FOCUS_FORWARD,
View.FOCUS_BACKWARD), returning the first or last focusable view in the hierarchy
respectively.
For absolute directional navigation (View.FOCUS_LEFT, View.FOCUS_RIGHT,
View.FOCUS_UP, View.FOCUS_DOWN), this method always uses the focused
view's bounding rectangle as the geometric starting point for the spatial search, regardless
of whether the view is included in the focusable sequence.
| Parameters | |
|---|---|
root |
ViewGroup: Contains focused. Cannot be null. |
focused |
View: Has focus now. |
direction |
int: Direction to look. |
| Returns | |
|---|---|
View |
The next focusable view, or null if none exists. |
findNextFocusFromRect
public View findNextFocusFromRect (ViewGroup root, Rect focusedRect, int direction)
Find the next view to take focus in root's descendants, searching from a particular rectangle in root's coordinates.
| Parameters | |
|---|---|
root |
ViewGroup: Contains focusedRect. Cannot be null. |
focusedRect |
Rect: The starting point of the search. |
direction |
int: Direction to look. |
| Returns | |
|---|---|
View |
The next focusable view, or null if none exists. |
findNextKeyboardNavigationCluster
public View findNextKeyboardNavigationCluster (View root, View currentCluster, int direction)
Find the root of the next keyboard navigation cluster after the current one.
| Parameters | |
|---|---|
root |
View: The view tree to look inside. Cannot be null |
currentCluster |
View: The starting point of the search. Null means the default cluster.
This value may be null. |
direction |
int: Direction to look.
Value is one of the following: |
| Returns | |
|---|---|
View |
The next cluster, or null if none exists |
getInstance
public static FocusFinder getInstance ()
Get the focus finder for this thread.
| Returns | |
|---|---|
FocusFinder |
|