android中rotateanimation怎样利用
在Android中,可使用RotateAnimation类来实现旋转动画。以下是一个简单的示例代码演示如何利用RotateAnimation:
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
android:duration="1000"
android:repeatCount="infinite" />
Animation animation = AnimationUtils.loadAnimation(this, R.anim.rotate);
view.startAnimation(animation);
其中,this是当前Activity的实例,view是要利用旋转动画的View。
这样就能够在View上利用旋转动画了。rotate.xml文件中定义了一个从0度到360度无穷循环的旋转动画,可以根据需求修改旋转的角度、中心点、延续时间等属性。
TOP