Search code examples
androidandroid-tvleanback

How to force Leanback navigation to observer up/down navigation buttons (Android TV app)


I have a page (MPV) that has 2 fragments in it. One is a top row of 3 featured videos, and the lower fragment is a multi-row view for different REST endpoints. There is only one issue with navigation that I cannot for the life of me fix.

Here is a picture of the layout: Navigation Issue

When navigating "Down" from the FeatureRow Fragment (the 3 box row), I want the navigation to just give focus to the ContentRow Fragment (the 6.5 box row).

Is there a setting in the XML where I can specify that the FeatureRow is full-width so that DOWN would indicate to move into the ContentRow fragment? Right now, you have to hit LEFT in order to get it to move 'down', but UP works just fine to get back up into the Feature row.

There's so much code to add, I'll provide any code that one would think useful to troubleshoot this. It's basically just standard leanback navigation without any custom navigation code, so I'm assuming there's a setting to make it work.


Solution

  • The solution was very dumb.

    Firstly, I had to set up a global focus listener to listen for focus changes to see where the focus was going.

    OnGlobalFocusChangeListener()

    Found out the focus was on rowContainer and not an item. Then discovered this line in my XML file for the home fragment rowContainer:

    android:focusable="true"

    This was allowing the container itself to be focused - not just the items inside of it. Removing that line eliminated the problem.