if (TextUtils.isEmpty(phone)) {
Toast.makeText(QuryActivity.this, "不能为空", 1000).show();
Animation shake = AnimationUtils.loadAnimation(this, R.anim.shake);
editText.startAnimation(shake);
然后利用位移动画设置抖动
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:fromXDelta="0"
android:interpolator="@anim/cycle_7"
android:toXDelta="10" />
从0到10开始懂持续时间1秒
震动7次
<cycleInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
android:cycles="7" />