本文实例讲述了Android开发简单实现摇动动画的方法。分享给大家供大家参考,具体如下:
1、先创建shake.xml
<?xml version="1.0" encoding="utf-8"?> <translate xmlns:android="http://schemas.android.com/apk/res/android" android:duration="700" android:fromXDelta="0.0" android:interpolator="@anim/cycle" android:toXDelta="15.0" />
2、创建cycle.xml
<?xml version="1.0" encoding="utf-8"?> <cycleInterpolator xmlns:android="http://schemas.android.com/apk/res/android" android:cycles="4.0" />
3、使用方式
Animation animation = AnimationUtils.loadAnimation(this, R.anim.shake); animation.setDuration(1000); animation.setRepeatMode(Animation.INFINITE); iv.startAnimation(animation);
希望本文所述对大家Android程序设计有所帮助。