首页 > 其他 > 详细

ValueAnimator 使用注意事项

时间:2018-11-10 11:39:51      阅读:268      评论:0      收藏:0      [点我收藏+]

1、动画时间:如果是xml定义的值,需要使用getResources().getInteger(int)获取值

2、动画重复次数:Integer.MAX_VALUE 改为Integer.MAX_VALUE>>2

 

mIconAnimator = new ValueAnimator();
mIconAnimator.setDuration(getResources().getInteger(android.R.integer.config_mediumAnimTime));
mIconAnimator.addUpdateListener(
new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
int rotation = (int) animation.getAnimatedValue();
Log.e("OkHttp", "rotation=" + rotation);
ivButtonIcon.setRotation(rotation);
}
}
);
mIconAnimator.setRepeatCount(1);
mIconAnimator.setInterpolator(new AccelerateDecelerateInterpolator());



mIconAnimator.cancel();
int from = (int) (ivButtonIcon.getRotation() % 360f);
int to = reset ? 0 : 90;
if (from == to) return;
mIconAnimator.setIntValues(from, to);
mIconAnimator.start();

 

ValueAnimator 使用注意事项

原文:https://www.cnblogs.com/cnmly/p/9938550.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!