Android activity Jump animation various effects finishing _android

Source: Internet
Author: User
Everyone who uses Android's native UI knows that Android's activity jump is a very stiff switch interface. In fact, Android's activity jumps can be set up in various animations. Here's a look at the effect:


Implementation is very simple, with overridependingtransition (int inId, int outid) can be implemented. iNID is the next interface to enter the effect of the XML file Id,outid is the current interface exit effect of the XML file ID.

The effect is written in an XML file, starting with the Anim folder under the Res folder, and then putting the animation effect XML file inside.
Here is an XML file that zooms in and shrinks the exit:
Zoomin.xml:
Copy Code code 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 the animation demo effect, the animation duration set to 3 seconds-->
<alpha
Android:fromalpha= "0.1"
Android:toalpha= "1.0"
Android:duration= "/>"
</set>

Zoomout.xml
Copy Code code 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 Code code 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 in and zoom out jump
StartActivity (This, Otheractivity.class) (new Intent);
if (Version > 5) {
Overridependingtransition (R.anim.zoomin, r.anim.zoomout);
}
Break
Case R.ID.BTN2:
Fade and Fade jump
StartActivity (This, Otheractivity.class) (new Intent);
if (Version > 5) {
Overridependingtransition (R.anim.alphain, r.anim.alphaout);
}
Break
Case R.ID.BTN3:
Jump left to right
StartActivity (This, Otheractivity.class) (new Intent);
if (Version > 5) {
Overridependingtransition (R.anim.move_in_right, r.anim.move_out_right);
}
Break
Case R.ID.BTN4:
Right to left jump
StartActivity (This, Otheractivity.class) (new Intent);
if (Version > 5) {
Overridependingtransition (R.anim.move_in_left, r.anim.move_out_left);
}
Break
}
Finish ();
}
}

There are many animation effects, we should play their own imagination, to design their own, hehe ~
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.