Java 我想让这张照片轻轻旋转
我已经研究过这个问题:在android中基于触摸事件以圆周运动移动图像,但它只告诉我如何沿圆周移动图像,而不是旋转图像Java 我想让这张照片轻轻旋转,java,android,Java,Android,我已经研究过这个问题:在android中基于触摸事件以圆周运动移动图像,但它只告诉我如何沿圆周移动图像,而不是旋转图像 尝试使用此代码旋转图像,希望是png或某种矢量 private fun rotateLoadingAnimation() { val rotate = RotateAnimation(0f, 180f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_
尝试使用此代码旋转图像,希望是png或某种矢量
private fun rotateLoadingAnimation() {
val rotate = RotateAnimation(0f,
180f, Animation.RELATIVE_TO_SELF,
0.5f, Animation.RELATIVE_TO_SELF,
0.5f)
rotate.duration = 5000
rotate.interpolator = LinearInterpolator()
ivRotating.startAnimation(rotate)
}
您可以使用
顺时针
旋转动画在res/anim/clockwiseanim.xml中实现这种形式的旋转
放置此代码
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/cycle_interpolator">
<rotate android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
android:duration="5000" />
</set>