FocusFinder
open class FocusFinder
| kotlin.Any | |
| ↳ | 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 | |
|---|---|
| open View! |
Find the nearest touchable view to the specified view. |
| View! |
findNextFocus(root: ViewGroup!, focused: View!, direction: Int)Find the next view to take focus in root's descendants, starting from the view that currently is focused. |
| open View! |
findNextFocusFromRect(root: ViewGroup!, focusedRect: Rect!, direction: Int)Find the next view to take focus in root's descendants, searching from a particular rectangle in root's coordinates. |
| open View! |
findNextKeyboardNavigationCluster(: View, : View?, : Int)Find the root of the next keyboard navigation cluster after the current one. |
| open static FocusFinder! |
Get the focus finder for this thread. |
Public methods
findNearestTouchable
open fun findNearestTouchable(
root: ViewGroup!,
x: Int,
y: Int,
direction: Int,
deltas: IntArray!
): View!
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 |
IntArray!: Offset from the to the edge of the nearest view. Note that this array may already be populated with values. |
| Return | |
|---|---|
View! |
The nearest touchable view, or null if none exists. |
findNextFocus
fun findNextFocus(
root: ViewGroup!,
focused: View!,
direction: Int
): View!
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. |
| Return | |
|---|---|
View! |
The next focusable view, or null if none exists. |
findNextFocusFromRect
open fun findNextFocusFromRect(
root: ViewGroup!,
focusedRect: Rect!,
direction: Int
): View!
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. |
| Return | |
|---|---|
View! |
The next focusable view, or null if none exists. |
findNextKeyboardNavigationCluster
open fun findNextKeyboardNavigationCluster(
: View,
: View?,
: Int
): View!
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: |
| Return | |
|---|---|
View! |
The next cluster, or null if none exists |
getInstance
open static fun getInstance(): FocusFinder!
Get the focus finder for this thread.