Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android, how to disable the 'wipe' effect when starting a new activity?

Tags:

android

In my application, how do I disable the transition animation that shows the new activity layout enter from the right and the old one exit to left?

Versions 2.0 -> 2.2 if relevant.

like image 931
Jim Blackler Avatar asked Dec 08 '22 02:12

Jim Blackler


2 Answers

CaseyB response is good we can set an animation

getWindow().setWindowAnimations(int);

but since Android SDK 2.0 you will use overridePendingTransition(), to change the transition animation, this is an example loading my App from the SplashScreen.

      @Override
      public void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.SplashScreen);

              new Handler().postDelayed(new Runnable() {
                      @Override
                      public void run() {
                              Intent mainIntent = new Intent(SplashScreen.this,     AndroidNews.class);
                              SplashScreen.this.startActivity(mainIntent);
                              SplashScreen.this.finish();

                              overridePendingTransition(R.anim.mainfadein,
                                      R.anim.splashfadeout);
                      }
              }, 3000);
      }

}

like image 196
Jorgesys Avatar answered Apr 08 '23 00:04

Jorgesys


Add this flag to your intent: android.content.Intent.FLAG_ACTIVITY_NO_ANIMATION.

Android docs states:

If set in an Intent passed to Context.startActivity(), this flag will prevent the system from applying an activity transition animation to go to the next activity state.

BTW: don't use it to set fire to an orphanage please :)

like image 27
Axel M. Garcia Avatar answered Apr 07 '23 22:04

Axel M. Garcia