I have added some animations on a view.
After launching an activity, all the animations are starting to animate. After stopping the animation effect I go to another activity that is in the same app. When I come back again to the activity that animation exists in, all animations start to animate again but it is not required.
I need to stop that animation effect after resume is called in an activity. I couldn't find any solutions for that. Any suggestions?
UPDATED:
I adding all the animation init and starting in the onCreate()
method.
UPDATED:
Animations are initiating in the onCreate()
method
sparkButton.setVisibility(View.GONE);
welcomeLayout.setVisibility(View.VISIBLE);
AnimationSet animationSet = new AnimationSet(true);
animationSet.setFillEnabled(true);
animationSet.setInterpolator(new BounceInterpolator());
Animation animation1 = AnimationUtils.loadAnimation(this, R.anim.welcome_slide_right_left);
animation1.setDuration(700);
animationSet.addAnimation(animation1);
final AnimationSet animationSet2 = new AnimationSet(true);
ScaleAnimation animation2 = new ScaleAnimation(1.0f, 0.14f, 1.0f, 1.0f, Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0.0f);
animation2.setDuration(400);
animation2.setStartOffset(400);
animationSet2.addAnimation(animation2);
animationSet.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
welcomeLayout.setAnimation(animationSet2);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
animationSet2.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
welcomeLayout.setVisibility(View.GONE);
sparkButton.setVisibility(View.VISIBLE);
sparkButton.playAnimation();
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
welcomeLayout.setAnimation(animationSet);
I put the source as shown above.
This issue needs to clarify and I will mark the answer as a hack solution. If whether this is an issue of Animation
object that we didn't handle correctly, That's what I want to resolve
UPDATED: The button activity to go to another activity
case R.id.spark_button: {
// network checking code will append here
// after that calls the activity
startActivity(new Intent(SettingsActivity.this, HomeActivity.class));
break;
}