3

I rotate an image view to point an arrow in the desired direction. Before performing the next rotation (using RotateAnimation), how can I get the currently rotated angle of the ImageView?

Thanks

mraviator
  • 4,034
  • 9
  • 38
  • 51
  • You can achieve this by extending RotateAnimation, see my answer [here][1] [1]: http://stackoverflow.com/questions/26139963/rotateanimation-get-current-angle/29168941#29168941 – rickul Mar 20 '15 at 14:33

2 Answers2

2

You need store your previous rotation angle in some variable.

1

Save rotate angle:

    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;
Praise Song
  • 187
  • 2
  • 2