RecyclerView: Animate item resize

后端 未结 2 1066
逝去的感伤
逝去的感伤 2021-02-02 12:38

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

相关标签:
2条回答
  • 2021-02-02 13:03

    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.

    0 讨论(0)
  • 2021-02-02 13:05

    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.

    0 讨论(0)
提交回复
热议问题