Search code examples
androidandroid-tvleanback

Android TV: Remove shadow from Item in ListRowPresenter


I am trying to remove shadow from the list item when that Horizontal list is not in focus. I am extending my fragment from RowSupportFragment and then creating ListRowPresenter like this

val listRowPresenter = ListRowPresenter(FocusHighlight.ZOOM_FACTOR_XSMALL)
    listRowPresenter.shadowEnabled = false
    ArrayObjectAdapter listRowAdapter = ArrayObjectAdapter(listRowPresenter)

and adding two ArrayObjectAdapter later on when data comes from server.

    listRowAdapter?.add(ListRow(null, objectAdapter1))
    listRowAdapter?.add(ListRow(null, objectAdapter2))

The line listRowPresenter.shadowEnabled = false is suppose to remove the shadow from the list rows but it is not giving the required behavior. Can anyone point to some classes or any example that can be helpful?


Solution

  • I found the solution for this i am posting it for future reference. If you want to remove the shadow from the items of unselected row you need to add these to you ListRowPresenter.

        listRowPresenter.shadowEnabled = false
        listRowPresenter.selectEffectEnabled = false
    

    and it will remove the shadow from the item. For more customization you can override ShadowOverlayHelper class that is initialized inside ListRowPresenter.