Added in API level 1

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!
findNearestTouchable(root: ViewGroup!, x: Int, y: Int, direction: Int, deltas: IntArray!)

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(root: View, currentCluster: View?, direction: 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

Added in API level 1
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

Added in API level 1
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.

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

Added in API level 1
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

Added in API level 26
open fun findNextKeyboardNavigationCluster(
    root: View,
    currentCluster: View?,
    direction: 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 android.view.View#FOCUS_BACKWARD, android.view.View#FOCUS_FORWARD, android.view.View#FOCUS_LEFT, android.view.View#FOCUS_UP, android.view.View#FOCUS_RIGHT, or android.view.View#FOCUS_DOWN
Return
View! The next cluster, or null if none exists

getInstance

Added in API level 1
open static fun getInstance(): FocusFinder!

Get the focus finder for this thread.