2013-02-12 97 views
1

我想旋轉箭頭指向某些特定位置旋轉圖像,以特定的方向

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(); 

但是它旋轉,不到一秒鐘內,它涉及到它原來的地方。我怎樣才能讓它像指南針一樣旋轉。

回答

2

另一種簡單的方式來旋轉的ImageView:

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

軸承角度我假設,但我將如何得到PivX和樞紐 – 2013-02-12 17:07:39

1

你有沒有嘗試過:

rotate.setFillAfter(true) 
1

只是儘量設置長動畫的,像

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