Search code examples
androidandroid-tvleanback

leanback library : How to draw focus for items in a VerticalGridView or HorizontalGridView?


Im playing around the leanback library , i can see for most of the RowsFragment in the leanback package, they are using either HorizontalGridView or VerticalGridView, but when I create a new HorizontalGridView, is not drawing the focus, which means i cant use my remote control to scroll to that item.

Anyone know how to do that?

Also I can see some of the presenters they are using ItemBridgeAdapter for their VerticalGridView or HorizontalGridView, is it related to get the focus of the views?


Solution

  • One possibility that I can think of that's causing this is that you haven't set your custom view to be both setFocusable(true) and setFocusableInTouchMode(true). You need these for whatever controls that you put into Leanback in order for the remote focus model to work.

    You can do these in both code and xml; in xml via android:focusable="true" and android:focusableInTouchMode="true" on the top level view that you want as your UI or card.