Android's activity jump is a very blunt switching interface. In fact, the activity of the Android jump can be set up a variety of animation, this article organized some, there are a lot of animation effect, it is up to us to play their own imagination we use Android native UI are aware that Android activity jump is very blunt switch interface. In fact, the Android activity jump can set various animations. Here's how it works:
Implementation is very simple, with overridependingtransition (int inId, int outid) can be implemented. iNID is the XML file ID of the current interface exit effect, which is the id,outid of the next interface entry effect XML file.
The effect is written in an XML file, the first to create a Anim folder under the Res folder, and then put the animation effect XML file inside.
Below is an XML file that zooms in and out of the exit:
Zoomin.xml:
Copy CodeThe code is as follows:
<?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= "0.1" android:toxscale= "1.0"
Android:fromyscale= "0.1" android:toyscale= "1.0"
android:pivotx= "50%p" android:pivoty= "50%p"
Android:duration= "/>"
<!--here to see an animated demo, set the animation duration to 3 seconds--
<alpha
Android:fromalpha= "0.1"
Android:toalpha= "1.0"
Android:duration= "/>"
</set>
Zoomout.xml
Copy CodeThe code is as follows:
<?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= "/>"
<!--system built-in animation duration
Android:duration= "@android: Integer/config_mediumanimtime"
-
<alpha android:fromalpha= "1.0" android:toalpha= "0"
Android:duration= "/>"
</set>
Mainactivity.java:
Copy CodeThe code is as follows:
public class Mainactivity extends Activity implements Onclicklistener {
Private Button btn1;
Private Button btn2;
Private Button btn3;
Private Button Btn4;
@Override
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (r.layout.activity_1);
BTN1 = (Button) Findviewbyid (R.ID.BTN1);
BTN2 = (Button) Findviewbyid (R.ID.BTN2);
Btn3 = (Button) Findviewbyid (R.ID.BTN3);
Btn4 = (Button) Findviewbyid (R.ID.BTN4);
Btn1.setonclicklistener (this);
Btn2.setonclicklistener (this);
Btn3.setonclicklistener (this);
Btn4.setonclicklistener (this);
}
@Override
public void OnClick (View v) {
TODO auto-generated Method Stub
int version = Integer.valueof (Android.os.Build.VERSION.SDK);
Switch (V.getid ()) {
Case R.ID.BTN1:
Zoom to zoom Out jump
StartActivity (New Intent (this, otheractivity.class));
if (Version > 5) {
Overridependingtransition (R.anim.zoomin, r.anim.zoomout);
}
Break
Case R.ID.BTN2:
Fade Jump
StartActivity (New Intent (this, otheractivity.class));
if (Version > 5) {
Overridependingtransition (R.anim.alphain, r.anim.alphaout);
}
Break
Case R.ID.BTN3:
Jump left to right
StartActivity (New Intent (this, otheractivity.class));
if (Version > 5) {
Overridependingtransition (R.anim.move_in_right, r.anim.move_out_right);
}
Break
Case R.ID.BTN4:
Right-to-left jump
StartActivity (New Intent (this, otheractivity.class));
if (Version > 5) {
Overridependingtransition (R.anim.move_in_left, r.anim.move_out_left);
}
Break
}
Finish ();
}
}
Android activity jump animation various effects finishing