Android implements page animation switching during Activity jump and finish

Source: Internet
Author: User

Android implements page animation switching during Activity jump and finish

Today, when shenyang binzi was working on an APP, the customer's demand was changed by adding an animation switch to the page in the original program, similar to the IPhone's left-out and right-in method, returns the opposite result. I know there are two ways to achieve this. One is to switch the animation by executing the overridePendingTransition method after startActivity, and the same is true for finish. The following is the encapsulated method:

 

/***** @ Description: The effect of the left-out and right-in jump to the page * @ Method_Name: startActivityAnim * @ param activity * @ return: void * @ Creation Date: 10:20:37 * @ version: v1.00 * @ Author: JiaBin * @ Update Date: * @ Update Author: JiaBin */public static void startActivityAnim (Activity activity, Class
 TLS) {Intent intent = new Intent (); intent. setClass (activity, linoleic); activity. startActivity (intent); // set the animation to switch from the right to exit the activity on the left. overridePendingTransition (R. anim. in_from_right, R. anim. out_to_left );}

Then read the original Coder code (a headache ~~~) I found that using my common method can meet the customer's needs, but there will be a lot of changes, which is a headache, so I want to use the second method, through xml configuration, make every one in AndroidManifest. the activities registered in xml are referenced in the configuration so that the customer's results can be achieved and the project can be changed to the minimum extent. The following is a method:

 

1. declare the following code in style. xml:

 

2. declare the following code in style. xml: 

 

 

3. Set and select the theme of every Activity in AndroidManifest. xml that requires this effect. The Code is as follows:

 

In the preceding three steps, you can switch between the animations that access the jump Activity. The corresponding animation files are attached below. 

 

In_from_right.xml

 

 
  
 

Out_to_left.xml

 

 

 
  
 

Push_left_in.xml

 

 


Push_left_out.xml

 

 

 
 
  
 

Push_right_in.xml

 

 

Push_right_out.xml

 

 

The above is the fragment code that needs to be used. If you need it, you can write the animation effect on your own and then meet your needs.

 

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.