An Activity switch animation is an animation that jumps from one Activity to another. It consists of two parts: one is the animation when the first activity exits; The other part is the animation when the second activity enters; After version 2.0 of Android, there is a function to help us implement this animation. This function is overridePendingTransition

@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); }Copy the code

The code above is just part of the splash screen.

getWindow (). setWindowAnimations ( int );    
getWindow (). setWindowAnimations ( int );
Copy the code

It’s not as good as the last one but it’s ok.

Achieve the effect of fade in and out 1:

overridePendingTransition(R.anim.splash_screen_fade, R.anim.splash_screen_hold);
Copy the code

Achieve the effect of fade in and out 2:

overridePendingTransition(android.R.anim.fade_in,android.R.anim.fade_out);     
Copy the code

Slide in from left to right:

overridePendingTransition(Android.R.anim.slide_in_left,android.R.anim.slide_out_right);     
Copy the code

implementationzoominandzoomoutThat is, iPhone-like entry and exit effects:

overridePendingTransition(R.anim.zoomin, R.anim.zoomout);    
overridePendingTransition(R.anim.zoomin, R.anim.zoomout);
Copy the code

Create a new zoomin.xml file:

<? xml version="1.0" encoding="utf-8"? > <set xmlns:Android="http://schemas.android.com/apk/res/android"
        Android:interpolator="@android:anim/decelerate_interpolator">
    <scale Android:fromXScale="2.0" android:toXScale="1.0"
           Android:fromYScale="2.0" android:toYScale="1.0"
           Android:pivotX="50%p" android:pivotY="50%p"
           Android:duration="@android:integer/config_mediumAnimTime" />
</set>
Copy the code

Create a new zoomout. XML file:

<? xml version="1.0" encoding="utf-8"? > <set xmlns:Android="http://schemas.android.com/apk/res/android"
       Android:interpolator="@android:anim/decelerate_interpolator"
       Android:zAdjustment="top">
   <scale Android:fromXScale="1.0" android:toXScale="5"
          Android:fromYScale="1.0" android:toYScale="5"
          Android:pivotX="50%p" android:pivotY="50%p"
          Android:duration="@android:integer/config_mediumAnimTime" />
   <alpha Android:fromAlpha="1.0" android:toAlpha="0"
           Android:duration="@android:integer/config_mediumAnimTime"/>
</set>  
Copy the code

The last

If you see this and you think it’s good, give it a thumbs up? If you think there is something worth improving, please leave a message. Will inquire seriously, correct inadequacy. thank you

I hope you can forward share and follow me, I will update the technical dry goods in the future, thank you for your support!

Like + follow + forward, the first time to get the latest knowledge

The road to being an Android architect is a long one.