I have a RecyclerView
. Each of its items of the recycler view can be either expanded or not. There can be only one item expanded at the same time.
In essence, I'm trying to re-create the history list in lolipop dialier.
I have found that using a LayoutTransition on RecyclerView makes it crash.
But I have not been able to correctly animate the item view change between both states.
I have tried getItemAnimator().setSupportsChangeAnimations(true)
in conjunction with notifyItemChanged(getPosition())
but there is two problems:
- The view is re-created, making the transition quite weird as it fades in above the next item at the same time as the item is moving. The new view that appears is not resizing, it is already at full size.
- As the view is re-created, the old view is fade out while the new is fade in, which makes the view background color flicker.
I have also tried setting a LayoutTransition
on the item view for the duration of the animation but the problem with this approach is that the layout of the RecycleView updates immediately and does not follow the animation.
I have created a small demo project of this issue for both tries. The projects sources are here.
How can I create a smooth transition on item layout change ?