旋转动画 - 车速表

时间:2016-02-17 20:38:49

标签: java android

我正在尝试使用图像(速度表和指针)来模拟速度表:

enter image description here

但当我将其旋转到90º时,结果如下:

enter image description here

以下是我使用的代码:

    RotateAnimation rotate = new RotateAnimation(0, 90, Animation.RELATIVE_TO_SELF, 1f, Animation.RELATIVE_TO_SELF, 0f);
    rotate.setDuration(5000);
    rotate.setFillAfter(true);
    mSpeedometerPointerImage.startAnimation(rotate);

我该怎么办?

修改

RotateAnimation

RELATIVE_TO_SELF

编辑2

只有两个参数:

enter image description here

1 个答案:

答案 0 :(得分:0)

在图像编辑器中打开图像,并精确定位图像旋转的确切位置,即:保持放置的位置。现在请注意该点的x,y坐标。现在第4个参数应该是一个浮点数,当乘以图像的宽度时,它将为您提供定义该点所需的x坐标,第6个参数应该是乘以时y坐标的相同乘数图像的高度。只是看着它(并且不知道是否有透明胶片等),在我看来数字将在0.8(x)和0.5(y)附近。希望这会有所帮助。