Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Leanback.DetailsFragment not scrolling as expected

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

like image 965
Redshirt Avatar asked Sep 04 '16 23:09

Redshirt


1 Answers

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.

like image 68
daemontus Avatar answered Sep 19 '22 17:09

daemontus