Android ImageView: how can I get the current rotation angle?

I rotate the image to point the arrow in the desired direction. Before doing the next rotation (using RotateAnimation), how can I get the current rotation angle of the ImageView?

thank

+3


source to share


2 answers


You need to store your previous rotation angle in some variable.



+2


source


Preserve rotation 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;

      

0


source







All Articles