将图像旋转到特定方向

时间:2013-02-12 16:36:14

标签: java android eclipse

我正在尝试旋转箭头指向某个特定位置

  float bearing = myLoc.bearingTo(mecca);
      RotateAnimation rotate = new RotateAnimation(0, bearing, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
      arrow.setAnimation(rotate);
      rotate.start();

然而它旋转并在不到一秒的时间内就会到达原来的位置。如何让它像指南针一样旋转。

3 个答案:

答案 0 :(得分:2)

旋转imageView的另一种简单方法:

Matrix matrix=new Matrix();
imageView.setScaleType(ScaleType.MATRIX);   //required
matrix.postRotate((float) angle, pivX, pivY);
arrow.setImageMatrix(matrix);

答案 1 :(得分:1)

你有没有尝试过:

rotate.setFillAfter(true)

答案 2 :(得分:1)

尝试设置动画的持续时间,例如

animation.setDuration(1500);
Where Duration is int(miliseconds)