本文實例講述了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程序設計有所幫助。
新聞熱點
疑難解答