Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to support dpad controls for RecyclerView

I am currently trying to port Android mobile app to Android TV. I have a RecyclerView that seems to be displaying correctly in my Android TV app. I am using linearLayout for my RecyclerView. But I don't seem to be able to navigate inside RecyclerView using dpad controls.

Any ideas?

Here is the concerned xml:

<android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/RecyclerView"
    android:layout_width="240dp"
    android:layout_height="match_parent"
    android:layout_gravity="left"
    android:background="@color/nav_bg"
    android:scrollbars="vertical"
    tools:showIn="@layout/activity_content" />

like image 395
Vpd Avatar asked Feb 11 '16 03:02

Vpd


2 Answers

Make root view of your item layout android:focusable="true"

like image 167
Gurgen Hakobyan Avatar answered Oct 02 '22 03:10

Gurgen Hakobyan


Try setting android:descendantFocusability="afterDescendants" on the RecyclerView

like image 35
TheoKanning Avatar answered Oct 02 '22 03:10

TheoKanning