1.资源文件anim下加入
cycles_anim.xml (插值器可以设置不同的插值器)
<?xml version="1.0" encoding="utf-8"?>
<cycleInterpolator xmlns:android="http://schemas.android.com/apk/res/android"android:cycles="2" />anim_rotate.xml
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"android:fromDegrees="-5"android:toDegrees="5"android:duration="1000"android:pivotX="50%"android:pivotY="100%"android:interpolator="@anim/cycles_anim" />findViewById(R.id.iv).setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {v.startAnimation(AnimationUtils.loadAnimation(MainActivity.this, R.anim.anim_rotate));}});
<?xml version="1.0" encoding="utf-8"?>
<ImageViewandroid:background="@color/colorAccent"android:id="@+id/iv"android:layout_centerInParent="true"android:layout_width="80dp"android:layout_height="80dp"
/>
```