2012-03-18 86 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;