gpt4 book ai didi

android - 使用 RotateAnimation 在 Android 中围绕固定点旋转 ImageView

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:42:39 32 4
gpt4 key购买 nike

我想围绕一个固定点连续旋转图像 360 度。我已经看过一些示例,例如:

RotateAnimation anim = new RotateAnimation(0, 360,150,150);
anim.setInterpolator(new LinearInterpolator());
anim.setRepeatCount(Animation.INFINITE);
anim.setDuration(2000);
[imageview].startAnimation(anim);

这确实会旋转图像,但它是在弧形/圆形路径上旋转的。 IE。图像以圆周运动移动/旋转,但并未固定在其起始位置。

我基本上想要的是模仿风车 ARM 的旋转。

有什么想法吗?

最佳答案

使用此代码

RotateAnimation rotateAnimation1 = new RotateAnimation(0, 360,
Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f);
rotateAnimation1.setInterpolator(new LinearInterpolator());
rotateAnimation1.setDuration(duration);
rotateAnimation1.setRepeatCount(0);
img.startAnimation(rotateAnimation1);

这将使您的图像在其固定位置旋转,即围绕自身旋转

关于android - 使用 RotateAnimation 在 Android 中围绕固定点旋转 ImageView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5213913/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com