(d) Android Animation development---Animation animation effect of the detailed

Source: Internet
Author: User

How Android uses animation we will do a detailed introduction to this article. You can read through the code cited here, and learn about the relevant operational skills, to facilitate our future development of applications, and deepen the understanding of this operating system.

In Android, animation can be defined in XML, or in program code, respectively.

Type of animation

Android animation is made up of four different types

in XML

Alpha Gradient Transparency Animation effect
Scale Gradient Dimension Stretch animation effect
Translate Move animation effect on picture transition position
Rotate Picture Transfer rotation animation effect



In Javacode

Alphaanimation Gradient Transparency Animation effect
Scaleanimation Gradient Dimension Stretch animation effect
Translateanimation Move animation effect on picture transition position
Rotateanimation Picture Transfer rotation animation effect


Android Animation mode

Animation There are two main modes of animation:
One is tweened animation (gradient animation)

in XML Javacode
Alpha Alphaanimation
Scale Scaleanimation



One is frame by frame (Picture conversion animation)

in XML Javacode
Translate Translateanimation
Rotate Rotateanimation




How to define animations in an XML file

① open Eclipse, new Android Project
② creating a new Anim folder in the Res directory
③ Create a new myanim.xml in the Anim directory (note the file name lowercase)
④ adding animated code to XML

<?XML version= "1.0" encoding= "Utf-8"?>  <Setxmlns:android= "Http://schemas.android.com/apk/res/android">    <Alpha/>    < Scale/>    <Translate/>    <Rotate/>  </Set>

Android Animation parsing--xml

<?XML version= "1.0" encoding= "Utf-8"?>  <Setxmlns:android= "Http://schemas.android.com/apk/res/android" >  <AlphaAndroid:fromalpha= "0.1"Android:toalpha= "1.0"android:duration= " the"/>   <!--transparency controls the animation effect Alpha Float value: The Fromalpha property is the Transparency Toalpha property at the beginning of the animation when the transparency description is at the end of the animation:              0.0 indicates full transparency 1.0 represents a full opacity value above a numeric long value that takes a float data type between 0.0-1.0: Duration property for animation duration Description: Time in milliseconds -  </Set>
<?XML version= "1.0" encoding= "Utf-8"?>  <Setxmlns:android= "Http://schemas.android.com/apk/res/android">     < ScaleAndroid:interpolator= "@android: Anim/accelerate_decelerate_interpolator"Android:fromxscale= "0.0"Android:toxscale= "1.4"Android:fromyscale= "0.0"Android:toyscale= "1.4"Android:pivotx= "50%"Android:pivoty= "50%"Android:fillafter= "false"android:duration= "The " />  </Set>  <!-- Size Stretch animation effect Scale property: interpolator Specifies an animated insert during my trial, there are three types of animation inserts found when using resources in Android.res.anim: Accelerate_decelerate_interpolator acceleration-deceleration animation Insert accelerate_interpolator acceleration-Animation plug Dec Elerate_interpolator Deceleration-Animation insert other properties that belong to a specific animation effect float value: The Fromxscale property is the start of the animation at the X-seat                  Scaling dimensions on the Toxscale property is the scaling dimension on the x-coordinate at the end of the animation Fromyscale property is the scaling dimension on the y-coordinate at the start of the animation                                   The Toyscale property is the scaling dimension on the y-coordinate at the end of the animation: four property values above 0.0 = Shrink to No 1.0 indicates normal no scaling value less than 1.0 indicates a shrinking value greater than 1.0 table                           Zoom Pivotx property is the start position of the animation relative to the object's x-coordinate Pivoty property is the start position of the animation relative to the object's y-coordinate Note: The above two attribute values from the 0%-100% value 50% is the object's X or y-direction coordinates on the midpoint position long integer value : Duration Property for animation Duration Description: Time in milliseconds Boolean value: Fillafter property When set to True, the animation conversion is applied after the animation is finished    -
<?XML version= "1.0" encoding= "Utf-8"?>  <Setxmlns:android= "Http://schemas.android.com/apk/res/android">  <TranslateAndroid:fromxdelta= "+"Android:toxdelta= " -80"Android:fromydelta= "+"Android:toydelta= "+"android:duration= "$"/>  <!--Translate position transfer animation effect integer value: The Fromxdelta property is the position on the x-coordinate at the start of the animation Toxdelta property is the bit on the x-coordinate at the end of the animation                       The Fromydelta property is the position of the y-coordinate at the start of the animation Toydelta property is the position of the y-coordinate at the end of the animation note: When Fromxtype Toxtype fromytype Toytype is not specified, the default is to use itself as a relative reference Long value: D Uration property for animation duration Description: Time in milliseconds -  </Set>
<?XML version= "1.0" encoding= "Utf-8"?>  <Setxmlns:android= "Http://schemas.android.com/apk/res/android">  <RotateAndroid:interpolator= "@android: Anim/accelerate_decelerate_interpolator"android:fromdegrees= "0"android:todegrees= "+350"Android:pivotx= "50%"Android:pivoty= "50%"android:duration= " the" />    <!-- Rotate rotation Animation effect properties: interpolator Specifies an animated insert during my trial, there are three types of animation inserts found when using resources in Android.res.anim:               Accelerate_decelerate_interpolator acceleration-deceleration animation Insert Accelerate_interpolator              Acceleration-Animation Insert Decelerate_interpolator deceleration-animation insert other types of floating-point values that belong to a particular animation effect:                       The Fromdegrees property is the angle of the object at the start of the animation Todegrees property is at the end of the animation when the angle of the object rotation can be greater than 360 degrees: When the angle is negative--indicates counterclockwise rotation when the angle is positive--Indicates a clockwise rotation (negative from--t                        O Positive: clockwise rotation) (negative from--to negative: counterclockwise rotation) (positive from--to positive: clockwise rotation)                    (Positive from--to negative number: counterclockwise rotation) The Pivotx property is the start position of the animation relative to the object's x-coordinate Pivoty property is the beginning of the animation relative to the object's y-coordinate              Note: The above two attribute values from 0%-100% value 50% are the long integer values of the midpoint position on the X or y-direction coordinates of the object: The Duration property is animatedDuration Description: Time in milliseconds    -  </Set>

This article is reproduced from http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2012/1113/548.html

(d) Android Animation development---Animation animation effect of the detailed

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.