View的抖动动画:
使用:
Animation shake = AnimationUtils.loadAnimation(this, R.anim.shake);
etNumber.startAnimation(shake);
/**
* 手机震动, 需要权限 android.permission.VIBRATE
*/
private void vibrate() {
Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
vibrator.vibrate(new long[] { 1000, 2000, 1000, 3000 }, -1);
}
cycle_7.xml
<?xml version="1.0" encoding="utf-8"?>
<cycleInterpolator xmlns:android="http://schemas.android.com/apk/res/android" android:cycles="7" />
shake.xml
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:fromXDelta="0"
android:interpolator="@anim/cycle_7"
android:toXDelta="10" />