2016-12-08 133 views

回答

1

這解決了我的問題。

public static ValueAnimator slideAnimator(int start, int end, final View view, int duration) { 
    ValueAnimator animator = ValueAnimator.ofInt(start, end); 
    animator.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); 
     } 
    }); 
    animator.setDuration(duration); 
    return animator; 
} 

感謝:Android property animation: how to increase view height?

0

嗯,這可以用 「一個班輪」 來完成:

TransitionManager.beginDelayedTransition(viewGroup); 

ViewGroup.LayoutParams layoutParams = view.getLayoutParams(); 
layoutParams.height = endValue; 
view.invalidate();