喷气背包中的rotateAnimation构成
我从GitHub上的一个项目中进行了这种旋转态度,我想将相同的旋转施加到我的图像(指南针带有针头箭头的指南),
这是rotateanimation的参数:
公共rotateyaimation(float fromdegrees,float fromDegrees,float todegrees,float todegrees,float todegrees,int pivotxtype,float pivotxvalue,float pivotxvalue,int int int pivotxvalue,float to PivotyType,float PivotyValue)
这是我的代码:
angleCompass.value = -angle
val an = RotateAnimation(
-currentAngle, -angle,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f
)
currentAngle = azimuth
an.duration = 500
an.repeatCount = 0
an.fillAfter = true
binding.imgCompass.startAnimation(an)
val anim = RotateAnimation(
-currentAngle + qiblaDir, -azimuth,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f
)
angleNeedle.value = -azimuth
currentAngle = azimuth
anim.duration = 500
anim.repeatCount = 0
anim.fillAfter = true
binding.imgQiblaArrow.startAnimation(anim)
如何在撰写中应用相同的动画?
I have this RotateAnimation from a project on GitHub and I want to apply the same rotation to my Image (Compass with needle arrow inside)
Here are the parameters of RotateAnimation:
public RotateAnimation(float fromDegrees, float toDegrees, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue)
Here is my code:
angleCompass.value = -angle
val an = RotateAnimation(
-currentAngle, -angle,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f
)
currentAngle = azimuth
an.duration = 500
an.repeatCount = 0
an.fillAfter = true
binding.imgCompass.startAnimation(an)
val anim = RotateAnimation(
-currentAngle + qiblaDir, -azimuth,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f
)
angleNeedle.value = -azimuth
currentAngle = azimuth
anim.duration = 500
anim.repeatCount = 0
anim.fillAfter = true
binding.imgQiblaArrow.startAnimation(anim)
How can I apply the same animation in compose?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简单的例子,但是您可以这样实现;
Simple example, but you can achieve like this;