Android Activity interface switch to add animation effects, Android activity
OverridePendingTransition () is available after Android 2.0. There are two parameters, one being the exit entry of the previous activity,
Java code
- @ 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 );
- }
The above code is only part of the pop-up screen.
Java code
- GetWindow (). setWindowAnimations (int );
This is not a good one, but also.
Fade in and out
Java code
- OverridePendingTransition (Android. R. anim. fade_in, android. R. anim. fade_out );
Effect of sliding from left to right
Java code
- OverridePendingTransition (Android. R. anim. slide_in_left, android. R. anim. slide_out_right );
Zoomin and zoomout are implemented, which is similar to the entry and exit effects of the iphone.
Java code
- OverridePendingTransition (R. anim. zoomin, R. anim. zoomout );
Create a zoomin. xml file
Xml Code
- <? 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: Ready Tx = "50% p" android: Ready ty = "50% p"
- Android: duration = "@ android: integer/config_mediumAnimTime"/>
- </Set>
Create a zoomout. xml file
Xml Code
- <? 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: Ready Tx = "50% p" android: Ready ty = "50% p"
- Android: duration = "@ android: integer/config_mediumAnimTime"/>
- <Alpha Android: fromAlpha = "1.0" android: toAlpha = "0"
- Android: duration = "@ android: integer/config_mediumAnimTime"/>
- </Set>
How does android implement sliding switching between multiple activity interfaces?
Fiddingin
Android development, in the same activity, you can achieve the animation effect when switching the layout.
How to switch two la s