I want to rotate image dynamically(Not by XML code). I am using this code to rotate the Image:
public void rotateAnimation(){
// Create an animation instance
Animation an = new RotateAnimation(30, 360);
// Set the animation's parameters
an.setDuration(2000); // duration in ms
an.setRepeatCount(0); // -1 = infinite repeated
an.setRepeatMode(Animation.REVERSE); // reverses each repeat
an.setFillAfter(true); // keep rotation after animation
// Aply animation to image view
scanCircle.setAnimation(an);
}
Using this code, My ImageView get rotate but its not on its position but outside to its position. I want is to rotate it on its own position.
So, How to make it possible ?
i think position pivotx & pivotY will helpful http://developer.android.com/reference/android/view/animation/RotateAnimation.html#RotateAnimation%28float,%20float,%20float,%20float%29
suppose if you want to rotate from middle then