Leanback.DetailsFragment not scrolling as expected
Asked Answered
B

3

11

I have a details fragment that is using a DetailsOverviewRow and FullWidthDetailsOverviewRowPresenter. When the page first loads the action buttons are selected. When I press down once, focus leaves the buttons and nothing else happens. When I press down a second time focus moves to a ListRow that is further down the page. I'm trying to figure out why the overview, or body as it's called in the presenter, section doesn't focus.

DetailsView initial state

DetailsView scrolled

Should there not be a second 'state' between the two screenshots where the overview/body is readable?

Possibly of note. The DetailsFragment isn't declared in an activities xml, I'm changing fragments manually using FragmentTransactions. Also, the Fragment is instantiated using a static create method (source below).

Thanks in advance.

Activity xml

DetailsFragment java

Borodino answered 4/9, 2016 at 23:37 Comment(0)
B
1

Hate to answer my own question. This was due to my failure to RTFM. I was creating the fragment UI after a network request completes. For the FullWidthDetailsPresenter to work properly it and the ClassPresenterSelector() should be initialized in the fragments onCreate() method.

Borodino answered 1/10, 2016 at 21:44 Comment(1)
can you explain more?Tashia
B
2

I haven't tried this example in particular, but from my time spent with Leanback support library, I learned that even though a lot of helpful stuff is indeed provided, a lot is not :D

So I would try these things:

1) Make sure that something in the area you want visible is focusable. (Clickable elements should be focusable by default, but better check too) What I mean is that on the screenshot, there is just text, no buttons or editable content in that area. So when you press down, there is nothing to focus. What happens if you make the body TextView focusable? (Yes, one would expect that the support library would take care of that, but that might not be the case.)

2) Find out what actually gets focused when you press down, since as you said, the focus leaves the buttons - but where does it go? (How to find out which view is focused?) You might have a "direction problem" somewhere. That is - the focus travels based on the view hierarchy tree, not based on what we see on the screen. In some cases, it is possible to skip some elements or get stuck somewhere by moving focus through an unexpected part of the view tree, that makes sense for the algorithm, but isn't logical from the human perspective.

Brokenhearted answered 12/9, 2016 at 16:14 Comment(1)
Thanks for the suggestions. After posting I found this article which is the same problem. #37719320. The answer didn't fix my issue, but at least let me know what is supposed to happen.Borodino
I
2

The details presenter focus works this way : 1) First focus is given to Action buttons. Right/left nav press shifts the focus right/left between action buttons.

2) Down nav press from actions row shifts the focus from actions row to details row (individual details items itself are not focusable), this is achieved by shifting the Thumbnail anchoring position to further south.

3) Down nav press from details row shifts the focus from details row to related row.

So the details row gains focus by changing the anchoring position of Thumbnail image. Is your thumbnail image changing its anchoring position when pressing down from actions row?

Irregularity answered 18/9, 2016 at 7:19 Comment(0)
B
1

Hate to answer my own question. This was due to my failure to RTFM. I was creating the fragment UI after a network request completes. For the FullWidthDetailsPresenter to work properly it and the ClassPresenterSelector() should be initialized in the fragments onCreate() method.

Borodino answered 1/10, 2016 at 21:44 Comment(1)
can you explain more?Tashia

© 2022 - 2024 — McMap. All rights reserved.