Search code examples
androidandroid-animationleanback

Create Zoom effect similar to leanback for ListView


I'm trying to create an effect for my ListView that is similar in looks to what Row items in Leanback do. I've tried looking through Presenter and ListRow as well as ObjectAdapter but haven't been able to define where these animations exist. They don't have to be 1:1 but the screenshot below is an example of what I'm trying to do.

Screenshot

The "essential" components for this are as follows:

  • Needs to animate on item focus to "inflate" or "expand"

  • When it's selected, it needs to have a shadow, similar to setting "elevation" for Material objects

  • When a new item comes into focus the old item needs to return to its previous state

This does not need to be leanback specific. I'm just looking for a generic version of what the leanback rows already do.


Solution

  • This scaling effect is handled by the ListRowPresenter in combination with the FocusHighlightHelper. The shadow is handled by a wrapper view ShadowOverlayContainer which is applied to the items by some other leanback class. If you want to use this in a non Android TV scenario (i.e no Leanback) you'd be better off creating a separate scale+elevation ValueAnimator animation on the currently selected list item in your RecyclerView or one of it's supporting classes.