shake.xml文件
<translate xmlns:android="http://schemas.android.com/apk/res/android" android:fromXDelta="0" android:toXDelta="10" android:duration="1000" android:interpolator="@anim/cycle_7" />
cycle_7.xml文件
<cycleInterpolator xmlns:android="http://schemas.android.com/apk/res/android" android:cycles="7" />
使用这个效果,只需下面两行代码:
Animation shake = AnimationUtils.loadAnimation(this, R.anim.shake); findViewById(R.id.xxxx).startAnimation(shake);