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< Span style= "color: #0000ff;" >= "0.0" /></set >             

Slide_left_out.xml out 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= "0.0"  Android:toxdelta= " -100.0%p" /></ set>        

Slide_right_in.xml, come 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, get out 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> <item name= "Android:activitycloseenteranimation" Span style= "color: #0000ff;" >> @anim/slide_left_in</item> <item name< Span style= "color: #0000ff;" >= "Android:activitycloseexitanimation" </item> </< Span style= "color: #800000;" >style>           

Android: Change activity switching mode

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.