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

前端 未结 3 1887
借酒劲吻你
借酒劲吻你 2021-02-06 15:32

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

3条回答
  •  北恋
    北恋 (楼主)
    2021-02-06 16:04

    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);
          }
    

    }

提交回复
热议问题