ValueAnimator.REVERSE为REVERSE创建不同的行为

时间:2014-07-09 06:28:14

标签: android animation

我有简单的动画,可以在Y轴上移动对象。我想改变REVERSE的行为。     //我的代码:

ImageView iv = ... //my view
ObjectAnimator oa = ObjectAnimator.ofFloat(iv, "y", 300);
oa.setDuration(100);   
oa.setRepeatCount(1);
oa.setRepeatMode(ValueAnimator.REVERSE);
oa.start();

1 个答案:

答案 0 :(得分:1)

您无法更改反向模式的行为。相反,您需要创建一个AnimatorSet并按顺序播放它们。

ImageView iv = ... //my view
ObjectAnimator oa = ObjectAnimator.ofFloat(iv, "y", 300);
oa.setDuration(100);
ObjectAnimator oa2 = ObjectAnimator.ofFloat(/* code here */)
// Add any other code for oa2
AnimatorSet set = new AnimatorSet();
set.playSequentially(oa, oa2);
set.start()