Skip to content

Most visited

Recently visited

navigation

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

From class java.lang.Object

Public methods

findNearestTouchable

added in API level 1
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 to the edge of the nearest view. Note that this array may already be populated with values.

Returns
View The nearest touchable view, or null if none exists.

findNextFocus

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

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

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

added in API level 26
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

Returns
View The next cluster, or null if none exists

getInstance

added in API level 1
FocusFinder getInstance ()

Get the focus finder for this thread.

Returns
FocusFinder

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience. (Dec 2017 Android Platform & Tools Survey)