finalLinearLayout.LayoutParams expandParams = (LinearLayout.LayoutParams)expandArea.getLayoutParams();
Interpolator mExpandInterpolator =newDecelerateInterpolator(EXPAND_DECELERATION);
ValueAnimator animator = ValueAnimator.ofFloat(0f,1f)
.setDuration(EXPAND_DURATION);
animator.setInterpolator(mExpandInterpolator);
animator.addUpdateListener(newValueAnimator.AnimatorUpdateListener() {
@Override
public voidonAnimationUpdate(ValueAnimator animator) {
Float value = (Float) animator.getAnimatedValue();
// For each value from 0 to 1, animate the various parts of the layout.
expandParams.height= (int) (value *EXPAND_HEIGHT);
expandArea.requestLayout();
}
});
// Set everything to their final values when the animation's done.
animator.addListener(newAnimator.AnimatorListener() {
@Override
public voidonAnimationEnd(Animator animation) {
// Set it back to wrap content since we'd explicitly set the height.
isExpand=true;
}
@Override
public voidonAnimationCancel(Animator animation) {
}
@Override
public voidonAnimationRepeat(Animator animation) { }
@Override
public voidonAnimationStart(Animator animation) { }
});
animator.start();