在res.anim文件下新建shake:
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="600"
android:fromXDelta="0"
android:toXDelta="10"
android:interpolator="@anim/cycle_7"/>
再新建一个cycle_7:
<cycleInterpolator xmlns:android="http://schemas.android.com/apk/res/android" android:cycles="7" />
然后往View上加动画就行了
Animation shake = AnimationUtils.loadAnimation(this, R.anim.shake);
View.startAnimation(shake);