2012-03-18 87 views
3

我旋轉圖像視圖以指向所需方向的箭頭。在執行下一次旋轉(使用RotateAnimation)之前,如何獲取ImageView的當前旋轉角度?Android ImageView:我怎樣才能獲得當前的旋轉角度?

謝謝

+0

您可以通過擴展RotateAnimation,看到我的答案[這裏]實現這一目標[1] [1]:http://stackoverflow.com/questions/26139963/rotateanimation,得到電流角/ 29168941#29168941 – rickul 2015-03-20 14:33:46

回答

2

您需要將您以前的旋轉角度存儲在某個變量中。

0

保存旋轉角度:

ImageView arrow = (ImageView) findViewById(R.id.arrow); 
    float x = arrow.getPivotX(); 
    float y = arrow.getPivotY(); 
    RotateAnimation anim = new RotateAnimation(arrowRotateStartAngle, arrowRotateXAngle, arrow.getWidth()/2, arrow.getHeight()/2); 
    anim.setFillAfter(true); 
    anim.setDuration(1000); 
    arrow.startAnimation(anim); 

    temRotate = arrowRotateStartAngle; 
    arrowRotateStartAngle = arrowRotateXAngle; 
    arrowRotateXAngle = temRotate;