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 essenc
You should just use notifyItemChanged(getPosition(), new Object())
instead.
In your adapter, override onBindViewHolder(GigExtraViewHolder holder, int position, List<Object> payloads)
, if payloads is null or empty do your original bind logics, else, just do your own expand/collapse animation.
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.