Vous pouvez utiliser la vue Recycleur extensible pour cela (disponible sur github). Si vous voulez utiliser la vue Recycleur, vous pouvez développer et réduire la vue avec animation comme une bascule. Consultez le code ci-dessous:
public static void expandCard(final View v) {
v.measure(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
final int targetHeight = v.getMeasuredHeight();
v.getLayoutParams().height = 1;
v.setVisibility(View.VISIBLE);
Animation a = new Animation()
{
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
v.getLayoutParams().height = interpolatedTime == 1
? ViewGroup.LayoutParams.WRAP_CONTENT
: (int)(targetHeight * interpolatedTime);
v.requestLayout();
}
@Override
public boolean willChangeBounds() {
return true;
}
};
a.setDuration(((int)(targetHeight/v.getContext().getResources().getDisplayMetrics().density))*6);
v.startAnimation(a);
}
public static void collapseCard(final View v) {
final int initialHeight = v.getMeasuredHeight();
Animation a = new Animation()
{
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
if(interpolatedTime == 1){
v.setVisibility(View.GONE);
}else{
v.getLayoutParams().height = initialHeight - (int)(initialHeight * interpolatedTime);
v.requestLayout();
}
}
@Override
public boolean willChangeBounds() {
return true;
}
};
a.setDuration(((int)(initialHeight/v.getContext().getResources().getDisplayMetrics().density))*6);
v.startAnimation(a);
}