Android RotateAnimation - 前后旋转箭头

发布于 2024-11-25 19:35:37 字数 529 浏览 6 评论 0原文

在我的应用程序中,我将时钟指针旋转到所需的分钟数。这对于旋转动画效果很好。现在我想做的是将手放回起始位置(0 分钟)。

例如: 我首先像这样旋转手:

final RotateAnimation anim = new RotateAnimation(0f, ammountDegress, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 1f);
anim.setFillAfter(true);
anim.setFillEnabled(true)

然后我想将手移回其起始位置,这意味着我应该在第一个动画结束后调用 RotateAnimation。

问题是枢轴已经改变,我怎样才能将枢轴位置设置为之前的确切位置?使旋转点再次位于钟针的同一位置。

编辑为了使它更清晰 - 我想要一个类似固定点枢轴的东西,它不会随着旋转而改变,所以我总是围绕同一点旋转手。

我希望你能明白我的意思。

In my application, I am rotating a clock hand to the desired amount of minutes. This works good with RotateAnimation. Now what I want to do is to return the hand back to the starting position (0 minutes).

For example:
I first rotate the hand like this:

final RotateAnimation anim = new RotateAnimation(0f, ammountDegress, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 1f);
anim.setFillAfter(true);
anim.setFillEnabled(true)

Then I would like to move the hand back to it's starting position, so that means I should be calling a RotateAnimation after the first animation ends.

The problem is that the pivots have changed, how I can I set the pivot position to the exact position as previous? So that the rotating point is again at the same position of the clock hand.

Edit To make it more clearer - I would like to have something like a fixed point pivot that doesn't change with the rotation, so I am always rotating the hand around the same point.

I hope you can understand what I mean.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文