0

I'm working with Android TV for the first time and I'm learning to use Leanback by modifying the example tv app that is provided.

The issue I'm having is that when I press left on the first item in the lists the navigation drawer opens and focus goes to the headers in the navigation drawer. When this happens, the info_field view in the ImageCardViews collapse behind the image.

What happens: The info field on the ImageCardView hides when I open the navigation drawer.

What I want to Happen: The info field remains visible when I open the navigation drawer.

I'm sure there's a way to do this because I've seen it in some Android TV apps, like Twitch. What's the best way to have the info_field visible when the navigation drawer is open?

ninjachippie
  • 410
  • 1
  • 5
  • 14

2 Answers2

0

I think if you look at this SO post you'll get most of the way there. The info view hides due to what leanback calls "expanding".

Try just calling enableMainFragmentScaling(false); in your BrowseFragment and see if that does what you want. If it doesn't feel like exactly what you want, refer to the post I linked to.

Additionally, if you've tried what I recommend in the linked SO post, you could also call the API on the BaseCardView setInfoVisibility() and pass it CARD_REGION_VISIBLE_ALWAYS. This just requires calling on a reference to your card which shouldn't need an override of the Presenter or Card.

Community
  • 1
  • 1
Kyle Venn
  • 4,597
  • 27
  • 41
  • Thanks for the reply, but that's not what I'm looking for. It just seems to disable the animation on expanding/collapsing the cells. – ninjachippie Sep 20 '16 at 15:41
  • I just modified my post which doesn't require overriding the `ImageCardView` and utilizes the APIs they provide on the `Card` object. I do recommend that you check out the linked SO post though since it has a more involved answer which should accomplish what you're doing. – Kyle Venn Sep 20 '16 at 18:34
0

I've worked out how to do it. In the CardPresenter, in onCreateViewHolder, when creating the ImageCardView I've overridden the BaseCardView method, setActivated(boolean activated) to always pass 'true' into it's super. And then call setActivated so that it's activated from the beginning. Like this:

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
ImageCardView cardView = new ImageCardView(parent.getContext()) {
        @Override
        public void setActivated(boolean activated) {
            super.setActivated(true);
        }
        @Override
        public void setSelected(boolean selected) {
            updateCardBackgroundColor(this, selected);
            super.setSelected(selected);
        }
    };

    cardView.setActivated(true);
    cardView.setFocusable(true);
    cardView.setFocusableInTouchMode(true);
    return new ViewHolder(cardView)
}

So that did the trick for me. The ImageCardView never collapses.

ninjachippie
  • 410
  • 1
  • 5
  • 14