Java tutorial
//package com.java2s; import android.view.View; import android.view.animation.Animation; import android.view.animation.Transformation; public class Main { private static final int ANIM = 400; public static void collapse(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(ANIM); v.startAnimation(a); } }