expandable-recycler-view
expandable-recycler-view copied to clipboard
Improve RecyclerView adapter change animations
First, great lib!
I have a use case where at most one parent can be expanded at any one time. Expanding a parent causes any other previously expanded parent to collapse. The problem I have is that the RecyclerView animation is strange: The children from the collapsing parent move to the newly expanding parent, rather than being removed (and new children added to the expanding parent). This looks very confusing to the user - children should not appear to move between parents.
How can I change this behavior so that children do not move between parents?
It seems making getChildViewType
unique for each child fixes this issue. But is this the correct approach?
@Override
public int getChildViewType( int parentPosition, int childPosition ) {
return 3 + parentPosition * mParentList.size() + childPosition;
}