Android 摇动动画

阅读 76

2023-03-06


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);


精彩评论(0)

0 0 举报