0

i'm working on a RecyclerView in Android which should contains expandable cards. I've already seen some questions like this or this but I can't figure out how to manage some things.

In my app (pic below) the expandable part is the one with the "maps" icon and "plus" icon.

Card expansion

During Google I/O 2016, Nick Butcher explained some of his code but i can't solve the part in which he divides the layout in two parts (the one that is always visibile itemView, and the expandable one, details) in the onBindViewHolder method.

final boolean isExpanded = position==mExpandedPosition;
holder.details.setVisibility(isExpanded?View.VISIBLE:View.GONE);
holder.itemView.setActivated(isExpanded);
holder.itemView.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        mExpandedPosition = isExpanded ? -1:position;
        TransitionManager.beginDelayedTransition(recyclerView);
        notifyDataSetChanged();
    }
});

Can anyone explain me this and the other parts that make the animation and the expansion possible? You could find useful the Heisenberg's reply in this question Thanks!

Edric
  • 24,639
  • 13
  • 81
  • 91
  • Possible duplicate of [Expand/collapse animation in CardView](http://stackoverflow.com/questions/41464629/expand-collapse-animation-in-cardview) – david.mar22 May 01 '17 at 15:18

2 Answers2

0

Ok Solved: it was enough to identify the "hidden" part in a layout and save it inside the viewholder.

0

Try adding the hidden part in the viewholder constructor and inflating the view that manage it

Silvio Biasiol
  • 856
  • 8
  • 14