Skip to content Skip to sidebar Skip to footer

Android Imageview: How Can I Get The Current Rotation Angle?

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 Ima

Solution 1:

You need store your previous rotation angle in some variable.

Solution 2:

Save rotate angle:

ImageViewarrow= (ImageView) findViewById(R.id.arrow);
    floatx= arrow.getPivotX();
    floaty= arrow.getPivotY();
    RotateAnimationanim=newRotateAnimation(arrowRotateStartAngle, arrowRotateXAngle, arrow.getWidth()/2, arrow.getHeight()/2);
    anim.setFillAfter(true);
    anim.setDuration(1000);
    arrow.startAnimation(anim);

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

Post a Comment for "Android Imageview: How Can I Get The Current Rotation Angle?"