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:
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 ?
OK, So I have found a solution that does not involve calling notifyItemChanged
so the view is not replaced. The con is that you have to manualy check the view consistency. For that, I have created a small library that allows exactly what I was looking for, for 5 loc in the ViewHolder.
The trick is to animate height change manualy rather than using a LayoutTransition.
The demo project can be found here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With