I want to rotate imageview with continuously looping on android.my code rotate is working perfectly with out set repeat mode.if i set repeat mode repeat animation not working but, imageview statically rotate some angle and i want loop rotate animation any one can help me with greatly appreciated!
here’s animation xml
<?xml version="1.0" encoding="utf-8"?>
<rotate
xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="45"
android:toDegrees="45"
android:pivotX="50%"
android:pivotY="50%"
android:duration="100"
android:startOffset="0"
/>
here’s my java class
import android.app.Activity;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
public class AnimationActivity extends Activity {
/** Called when the activity is first created. */
ImageView my_image;
AnimationListener listener;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
listener = new AnimationListener() {
@Override public void onAnimationStart(Animation animation) {}
@Override public void onAnimationRepeat(Animation animation) {}
@Override
public void onAnimationEnd(Animation animation) {
System.out.println("End Animation!");
//load_animations();
}
};
my_image=(ImageView)findViewById(R.id.my_img);
load_animations();
}
void load_animations()
{
new AnimationUtils();
Animation rotation = AnimationUtils.loadAnimation(this, R.anim.rotation);
rotation.setRepeatCount(-1);
rotation.setRepeatMode(2);
rotation.setAnimationListener(listener);
my_image.startAnimation(rotation);
}
}
Thanks in Advance!
finally,i got solution try below xml:
here’s my class
That’s the code is working perfectly!
My problem was solved!