1.TranslateAnimation位移动画
translate_animation.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="2000"
android:fillAfter="true"
android:repeatMode="restart" android:interpolator="@android:anim/accelerate_decelerate_interpolator">
<translate
android:repeatCount="2"
android:fromXDelta="0"
android:fromYDelta="0"
android:toXDelta="100"
android:toYDelta="0"/>
</set>
2.代码实现
//Animation mAnimation = AnimationUtils.loadAnimation(MainActivity.this,R.anim.scale_animation);
//mImg.startAnimation(mAnimation);
ScaleAnimation animation = new ScaleAnimation(1, 2, 1, 2,
RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
//不停顿
animation.setInterpolator(new LinearInterpolator());
//重复次数
animation.setRepeatCount(0);
animation.setFillAfter(true);
animation.setDuration(2000);
//开启动画
mImg.startAnimation(animation);