0

My android app currently uses android cardview. However I want to make the cardview focusable so that it can be used on android tv with a remote. At the moment you cannot see what option you are selecting with a remote as it looks no different to the original.

How can I make it so that when the cardview item is hovered it gets a gray tint or outline or something to show what option is selected?

Abhinav Suman
  • 940
  • 1
  • 9
  • 29

3 Answers3

0

This is not the CardView issue as per my understanding.(I am not too much experienced in Android TV)

you have to check about the ListView Highlighter and right your own code for highlighting the selected Row and Item at the same time dimming the inactive row.

I would recommend to use Selector available to make the item Focusable.

This link may helps you further.

  1. https://medium.com/androiddevelopers/customizing-leanback-for-android-tv-3f8d4a0b2839

  2. https://developer.android.com/training/tv/start/navigation#focus-selection

Abhinav Suman
  • 940
  • 1
  • 9
  • 29
0

If I understood your question correctly the issue is not that the views are not focusable, but rather that you cannot see which view is in focus. One solution to this is to set the useFocusDimmer flag in your ListRowPresenter. This can be done in the constructor: public ListRowPresenter(int focusZoomFactor, boolean useFocusDimmer) {}

Breiby
  • 554
  • 5
  • 14
0

You can find different solutions for this with different perspective:

1.You can use cardview with googles lean back library for android tv. Its the ultimate and perfect solution you can find.The card focus will be handled automatically here.

2.You can set multiple colour background for the different states of the ui component[Here the cardview]using a drawable with states manged with respective colour..

Freny John
  • 36
  • 2