AnimationSet包含了一系列的Animations,效果叠加。
代码方式:
AnimationSet set = new AnimationSet(false);
TranslateAnimation tAnim = new TranslateAnimation(0, 300, 0, 0);
tAnim.setInterpolator(new AccelerateDecelerateInterpolator());
ScaleAnimation sAnima = new ScaleAnimation(0, 2, 0, 2);
set.addAnimation(tAnim);
set.addAnimation(sAnima);
set.setDuration(2000);
view.startAnimation(set);
xml方式:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromXDelta="0"
android:toXDelta="300"
android:fromYDelta="0"
android:toYDelta="0"
android:duration="2000"/>
<scale android:fromXScale="0"
android:toXScale="2"
android:fromYScale="0"
android:toYScale="2"
android:duration="2000"/>
</set>