今天做项目的时候,设计的有这样一个图案的钟摆效果觉得挺有意思,所有记录xml的动画如下。
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:fromDegrees="-8"
android:pivotX="50%"
android:pivotY="0%"
android:repeatCount="infinite"
android:repeatMode="reverse"
android:toDegrees="8" />
d调用代码
Animation shake = AnimationUtils.loadAnimation(
ShakeDemoActivity.this, R.anim.anim);
shake.reset();
shake.setFillAfter(true);
image.startAnimation(shake);