In this paper, an example shows the Android implementation of the activity interface switch to add animation effects, for the Android program designers have a good reference value. The specific methods are as follows:
People who know about Android design should know that after Android 2.0 there is a overridependingtransition () with two parameters, one of which is the exit of the previous activity, and the other activity enters.
Now take a look at the sample code below:
@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 code above is just a part of the splash screen.
GetWindow (). setwindowanimations (int);
It's not a good last, but it's OK.
To achieve the effect of fading:
Overridependingtransition (android.r.anim.fade_in,android. R.anim.fade_out);
The effect of sliding from left to right:
Overridependingtransition (android.r.anim.slide_in_left,android. R.anim.slide_out_right);
Achieve ZoomIn and zoomout, that is, similar to the iphone's entry and exit effects:
Overridependingtransition (R.anim.zoomin, r.anim.zoomout);
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>
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>
It is believed that the example mentioned in this article has some reference value for the Android program design.