Android ValueAnimator onAnimationUpdate 无法正常工作

Android ValueAnimator onAnimationUpdate doesn't work correctly

当我使用 属性 动画时,它无法正常工作。以下是我的代码。单击视图执行切换动画,但未达到预期 result.The 日志显示 "onAnimationUpdate" 的回调仅被调用两次并返回了最大值。

 @Override
 public void onClick(View v) {
     switch (v.getId()) {
        case R.id.product_item_top_rl: 
        startAnimation(v);
        break;
     }
 }


private void startAnimation(final View v) {
    int height = v.getHeight();
    ValueAnimator va = ValueAnimator.ofInt(0, height);
    va.setDuration(1000);
    va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        public void onAnimationUpdate(ValueAnimator animation) {
            Log.d(TAG, "animation : " + animation.getAnimatedValue());
            v.getLayoutParams().height = (Integer) animation.getAnimatedValue();
            v.requestLayout();
        }
    });
    va.start();
}

这是日志。

D/ChooseProductFragment: animation : 150
D/ChooseProductFragment: animation : 150

我解决了 finally.The 问题是当我用浓缩咖啡做了 UI 几天测试时,我只是关闭了测试设备上的动画 ago.Then 我打开了动画现在可以使用了。