Java tutorial
//package com.java2s; //License from project: Open Source License import android.animation.ValueAnimator; import android.view.View; import android.view.ViewGroup; public class Main { public static void animateHeight(final View view, int from, int to, int duration) { boolean expanding = to > from; ValueAnimator anim = ValueAnimator.ofInt(from, to); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { int val = (Integer) valueAnimator.getAnimatedValue(); ViewGroup.LayoutParams layoutParams = view.getLayoutParams(); layoutParams.height = val; view.setLayoutParams(layoutParams); } }); anim.setDuration(duration); anim.start(); view.animate().alpha(expanding ? 1 : 0).setDuration(duration / 2).start(); } }