实现抖动是采用的Animation动画
shake.xml文件
cycle_7.xml文件
使用这个效果,只需下面两行代码:
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" />
- <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