Reputation: 5418
I want 1st my layout zoom up, 2nd it should zoom out with bounce. But this code doesn't work correctly.
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:ordering="sequentially" >
<set>
<scale
android:duration="400"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="1.2"
android:toYScale="1.2" />
</set>
<set android:interpolator="@android:anim/bounce_interpolator" >
<scale
android:duration="800"
android:fromXScale="1.2"
android:fromYScale="1.2"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="1.0"
android:toYScale="1.0" />
</set></set>
Upvotes: 0
Views: 3195
Reputation: 5338
I don't know much about object animator but i did scaling with property animation several times and it worked just fine! here is the code
AnimatorSet set = new AnimatorSet(); //this is your animation set.
//add as many Value animator to it as you like
ValueAnimator scaleUp = ValueAnimator.ofFloat(1,(float)1.2);
scaleUp.setDuration(800);
scaleUp.setInterpolator(new BounceInterpolator()); //remove this if you prefer default interpolator
scaleUp.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
Float newValue = (Float) valueAnimator.getAnimatedValue();
yourView.setScaleY(newValue);
yourView.setScaleX(newValue);
}
});
ValueAnimator scaleDown = ValueAnimator.ofFloat((float)1.2,1);
scaleDown.setDuration(800);
scaleDown.setInterpolator(new BounceInterpolator());
scaleDown.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
Float newValue = (Float) valueAnimator.getAnimatedValue();
yourView.setScaleY(newValue);
yourView.setScaleX(newValue);
}
});
set.play(saceleUp);
set.play(scaleDown).after(scaleUP);
set.start();
Upvotes: 5