@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
天蓬老师2017-04-17 15:38:28
Problem solved. It's because yesterday, in order to use espresso for UI automation testing, I turned off the three animations "Window Animation Scaling", "Excessive Animation Scaling", and "Animation Program Duration Adjustment" in the settings. Re-enable these animations and it will be normal.
迷茫2017-04-17 15:38:28
You did not specify the number and method of looping the animation, you should add
//无限循环
va.setRepeatCount(ValueAnimator.INFINITE);
//从头开始动画
va.setRepeatMode(ValueAnimator.RESTART);