左右摇摆的原理,就是向一个方向移动,然后设置反方向的属性。再设置重复次数。
TranslateAnimation animation = new TranslateAnimation(0, -5, 0, 0);animation.setInterpolator(new OvershootInterpolator());animation.setDuration(100);animation.setRepeatCount(3);animation.setRepeatMode(Animation.REVERSE);login_layout.startAnimation(animation);
对于这个login_layout,他是个view.就行。