我希望第一个我的布局放大,第二个它应该用弹跳缩小。但是这段代码没有正常工作。
<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>
答案 0 :(得分:3)
我对对象动画师了解不多,但我曾多次使用属性动画进行缩放,效果很好!这是代码
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();