public void animHeightView(final View view, final int start, final int end, long duration) { ValueAnimator animator = ValueAnimator.ofInt(start, end); final ViewGroup.LayoutParams layoutParams = v.getLayoutParams(); animator .addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { layoutParams.height = (int) animation.getAnimatedValue(); view.setLayoutParams(layoutParams); view.requestLayout(); } }); animator.setDuration(duration); animator.start();}
mContentView.postDelayed(new Runnable() { @Override public void run() { ((LinearLayout.LayoutParams) mContentView.getLayoutParams()).weight = 1.0F; // 刷新布局 mContentView.requestLayout(); }}, 200L);
若没有调用requestLayout(),可能布局不会刷新