Skip to content

Problems with D-pad navigation #40

@joharei

Description

@joharei

I'm using the library in an Android TV app, so navigation with D-pad is a requirement for me. When I press down in a list, the focusing works correctly until I reach the last displayed row. Pressing down from there does nothing, and onFocusSearchFailed() is called in the layout manager.

I've worked around this by subclassing the layout manager and scrolling a little when the focus search fails:

override fun onFocusSearchFailed(focused: View, focusDirection: Int,
                                 recycler: RecyclerView.Recycler, state: RecyclerView.State): View? {
    // Need to be called in order to layout new row
    scrollVerticallyBy(when (focusDirection) {
        View.FOCUS_DOWN -> 10
        View.FOCUS_UP -> -10
        else -> 0
    }, recycler, state)

    return super.onFocusSearchFailed(focused, focusDirection, recycler, state)
}

But there is probably a better way to do this.

Thanks for the nice library!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions