I'm working on a screen that contains an animation that is repeated every time the screen is rotated. I looked for but I did not find any precise information on what I need to do so that the animation does not repeat itself when changing the orientation of the device.
This is the Activity code in question:
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.LinearLayout;
public class Login extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
ImageView imgLogo = (ImageView) findViewById(R.id.imageView1);
final LinearLayout LoginBox = (LinearLayout) findViewById(R.id.LoginBox);
LoginBox.setVisibility(View.GONE);
Animation animTranslate = AnimationUtils.loadAnimation(Login.this,
R.anim.anim_logo);
animTranslate.setFillAfter(true);
animTranslate.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation arg0) {
}
@Override
public void onAnimationRepeat(Animation arg0) {
}
@Override
public void onAnimationEnd(Animation arg0) {
LoginBox.setVisibility(View.VISIBLE);
Animation animFade = AnimationUtils.loadAnimation(Login.this,
R.anim.anim_login);
LoginBox.startAnimation(animFade);
}
});
imgLogo.startAnimation(animTranslate);
}
}
By reading a little about the lifecycle of an Activity, I saw it re-enter every time the device is rotated. The question that remains is: which code do I need to implement so that the animation is not repeated?