Initial parsing of Android XML animation (jump demo between activity interface)

Source: Internet
Author: User

The previous article Android simply set the activity interface of the jump rotation to tell the simple activity interface between the jump, and using some Android built-in animation, this chapter on how to write some of their own animation to jump.


Routinely, or the last effect: (the end of thesource code attached)




To write your own animation, you must first understand some of the properties of the animation:

Interpolator : used to modify animation effect, define the rate of change of animation, can make the existing animation effect accelerated (acceleration), decelerated (deceleration), repeated (repetition), bounced (bounce) and so on.

android:duration: the duration of the animation.

Pivotx and Pivoty: these two properties control the pivot position of the view object and rotate and scale the transformation around the pivot point. By default, the position of the pivot point is the center of the View object.

Translate: (with x and y) This is the property as an increment that controls where the view object shifts from the upper-left coordinate of its layout container.

Rotate: This property controls the 2D rotation of the view object around its pointer.

Scale : (with x and Y) This property controls the 2D zoom of the View object around its pointer.

Alpha: it represents the transparency of the View object. The default value is 1 (opaque), and 0 is fully transparent (not visible).


The author has been very keen to describe the clarity of some, the novice just look at the solution may also Conceptual rationale There is a big problem, in the following demo code in the hope that you can give the reader some help again.

Demo or relatively simple, only to achieve the two activity between the jump, mainly in the XML file needs the reader to understand, of course, I can try the demo is still limited, interested readers can self-study a bit.


Paste the code:



Mainactivity:

Package Com.example.animationchanges;import Android.app.activity;import Android.content.intent;import Android.os.bundle;import Android.view.view;import Android.widget.button;public class MainActivity extends Activity {@        Override protected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);        Setcontentview (R.layout.activity_main);        Button button= (button) Findviewbyid (R.id.button);                Button.setonclicklistener (New View.onclicklistener () {@Override public void OnClick (View v) {                Intent intent=new Intent (mainactivity.this,oneactivity.class);                StartActivity (Intent); Set jump to rotate picture//overridependingtransition (r.anim.scale_in,r.anim.scale_out);//Overridependingtra                Nsition (r.anim.rotate_in,r.anim.rotate_out);            Overridependingtransition (r.anim.translate_in,r.anim.translate_out);    }        }); }}

Rotate_in:

<?xml version= "1.0" encoding= "Utf-8"? ><set xmlns:android= "Http://schemas.android.com/apk/res/android" ><rotate    android:duration= "@android: Integer/config_mediumanimtime"    android:fromdegrees= "0"    "50%p"    android:pivoty= "50%p" android:todegrees= "android:pivotx="    /></set>

Rotate_out:

<?xml version= "1.0" encoding= "Utf-8"? ><set xmlns:android= "Http://schemas.android.com/apk/res/android" ><rotate    android:duration= "@android: Integer/config_mediumanimtime"    android:fromdegrees= "360"    android:pivotx= "50%p"    android:pivoty= "50%p"    android:todegrees= "0"    /></set>


Scale_in:

<?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:duration= "@ Android:integer/config_mediumanimtime "        android:fromxscale=" 2.0 "        android:fromyscale=" 2.0 "        android: Toxscale= "1.0"        android:toyscale= "1.0"        android:pivotx= "50%p"        android:pivoty= "50%p"        /></ Set>

Scale_out:

<?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:duration= "@android: Integer/config_mediumanimtime"        android:fromxscale= "1.0"        android: Fromyscale= "1.0"        android:toxscale= ". 5"        android:toyscale= ". 5"        android:pivotx= "50%p"        android: pivoty= "50%p"/>    <alpha        android:duration= "@android: Integer/config_mediumanimtime"        android: Fromalpha= "1.0"        android:toalpha= "0"/></set>

Translate_in:

<?xml version= "1.0" encoding= "Utf-8"? ><set xmlns:android= "Http://schemas.android.com/apk/res/android"    android:interpolator= "@android: Anim/decelerate_interpolator" >    <translate        android:duration= " @android: Integer/config_mediumanimtime "        android:fromydelta=" 50%p "        android:toydelta=" 0 "/></set >

Translate_out:

<?xml version= "1.0" encoding= "Utf-8"? ><set xmlns:android= "Http://schemas.android.com/apk/res/android"    android:interpolator= "@android: Anim/decelerate_interpolator" >    <translate        android:duration= " @android: Integer/config_mediumanimtime "        android:fromydelta=" 0 "        android:toydelta=" 50%p "/></set >



Source Address: http://download.csdn.net/detail/double2hao/9414154




Initial parsing of Android XML animation (jump demo between activity interface)

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.