Android: Change activity switching mode

Source: Internet
Author: User

Overridependingtransition (Enteranim, Exitanim);

Intent Intent =new Intent (this,item2.class); startactivity (Intent); This.finish ();

For the whole application to change the way, then use style control it

1. Create Anim folder in Res folder

2. Add the following files:

Slide_left_in.xml in from the left.

 <?  xml version= "1.0" encoding= "Utf-8"  ?>  <  set  xmlns:android  = "Http://schemas.android.com/apk/res/android"     >  <  translate  android:duration  = "  Android:fromxdelta  = " -100.0%p"   Android:toxdelta  = "0.0"  />  </ set  >  

 <?  xml version= "1.0" encoding= "Utf-8"  ?>  <  set  xmlns:android  = "Http://schemas.android.com/apk/res/android"     >  <  translate  android:duration  = "  Android:fromxdelta  = "0.0"   Android:toxdelta  = " -100.0%p"  />  </ set  >  

Slide_right_in.xml comes in from the right

 <?  xml version= "1.0" encoding= "Utf-8"  ?>  <  set  xmlns:android  = "Http://schemas.android.com/apk/res/android"     >  <  translate  android:duration  = "  Android:fromxdelta  = "100.0%p"   Android:toxdelta  = "0.0"  />  </ set  >  

Slide_right_out.xml   Go from the right

 <?  xml version= "1.0" encoding= "Utf-8"  ?>  <  set  xmlns:android  = "Http://schemas.android.com/apk/res/android"     >  <  translate  android:duration  = "  Android:fromxdelta  = "0.0"   Android:toxdelta  = "100.0%p"  />  </ set  >  

Properties explained:

Translate position transfer animation effect

Android:fromxdelta= "0"-----------starting from 0 coordinates
Android:toxdelta= " -100%p"------move distance to parent level-100%

Two parameters are the offset distance of the charge relative to the parent

Android:duration= "-----------duration"

3. Modify Theme Styles

    <!--application theme. -    <stylename= "Apptheme"Parent= "Appbasetheme">        <!--All customizations, that is, specific to a particular api-level can go. -        <Itemname= "Android:windowanimationstyle">@style/activityanimation</Item>    </style>        <stylename= "Activityanimation"Parent= "@android: Style/animation">          <Itemname= "Android:activityopenenteranimation">@anim/slide_right_in</Item>          <Itemname= "Android:activityopenexitanimation">@anim/slide_left_out</Item>          <Itemname= "Android:activitycloseenteranimation">@anim/slide_left_in</Item>          <Itemname= "Android:activitycloseexitanimation">@anim/slide_right_out</Item>      </style>  

Example Download >>>>>>>>>>>>>

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.