Android animation effects translate, scale, alpha, rotate detailed

Source: Internet
Author: User

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 picture conversion position Move animation effect

Rotate Picture Transfer rotation animation effect


In Javacode

Alphaanimation Gradient Transparency animation effect

Scaleanimation Gradient dimension stretch animation effect

Translateanimation picture conversion position Move animation effect

Rotateanimation Picture Transfer rotation animation effect


Android Animation mode


Animation There are two main modes of animation:


One is tweened animation (gradient animation)

XML in Javacode

Alpha alphaanimation

Scale scaleanimation


One is frame by frame (Picture conversion animation)

XML in Javacode

Translate translateanimation

Rotate rotateanimation


Android Animation parsing

Alpha XML fade-in effect

<?xml version= "1.0" encoding= "Utf-8"?> <set xmlns:android= "Http://schemas.android.com/apk/res/android" > <alpha android:fromalpha= "1.0" android:toalpha= "0.0" android:duration= "/>" </set> < !--Fromalpha: Start transparency Toalpha: End Transparency Duration: duration of animation--

rotate.xml Rotation effect:  

<?xml version= "1.0"  encoding= "Utf-8"? > <set xmlns:android= "Http://schemas.android.com/apk/res/android" ><rotate      android:interpolator= "@android: Anim/accelerate_decelerate_interpolator"  android: Fromdegrees= " android:todegrees=" -360 " android:pivotx=" 10% " android:pivoty=" 100% "  Android:duration= "10000"  /> </set> <!--    fromDegrees    The angle at the beginning of the animation    toDegrees     the rotation angle of the object at the end of the animation, which means clockwise      The  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      --> 

SC Ale.xml Zoom effect:  

<?xml version= "1.0"  encoding= "Utf-8"? > <set xmlns:android= "http// Schemas.android.com/apk/res/android "> <scale   android:interpolator= " @android: Anim/decelerate_interpolator "   android:fromxscale=" 0.0 "   android:toxscale=" 1.5 "   android:fromyscale=" 0.0 "   android:toyscale=" 1.5 "   android: pivotx= "50%"    android:pivoty= "50%"    android:startoffset= "0"     Android:duration= "10000"   android:repeatcount= "1"    android:repeatmode= "reverse"   /> </set> <!--  fromXDelta,fromYDelta    initial x, y coordinates, The coordinates in the lower right corner of the screen are the coordinates of x, y at the end of the x:320,y:480 toxdelta, toydelta      animation  -->  <!--  interpolator                      Specify an acceleration reducer common to the animation Insert         accelerate_decelerate_interpolator Accelerator plug     accelerate_interpolator, decelerate the     decelerate_interpolator of the insertion device.  fromXScale,fromYScale,          x, y zoom before animation starts, 0.0 is not displayed,   1.0 is a multiple of the final scale of the normal size toxscale,toyscale,         animation,  1.0 is normal size, Greater than 1.0 magnification pivotx,  pivoty     animation start position, relative to the screen percentage, two are 50% means that the animation starts from the middle of the screen  startoffset,      the interval of time that the animation is executed multiple times, if only once, the time before execution is paused,     unit milliseconds  duration, the time the animation effect consumes, Unit millisecond,     value the smaller the animation speed  repeatcount, the animation repeats the count, the animation will execute that value + 1 times       Repeatmode, the animation repeats the pattern, the reverse is reversed, and when the first even executes, the animation is in the opposite direction.     restart for re-execution, direction invariant  -->

translate.xml Move Effect:  

<?xml version= "1.0" encoding= "Utf-8"?> <set xmlns:android= "Http://schemas.android.com/apk/res/android" ><translate android:fromxdelta= "android:toxdelta=" 0 "android:fromydelta=" 480 "android:toYDelta=" 0 " android:duration= "10000"/> </set> <!--Fromxdelta,fromydelta the start of the x, y coordinates, the lower right corner of the screen is x:320,y:480 Toxdelta, Toydelta the coordinates of x, y at the end of the animation


Android animation effects translate, scale, alpha, rotate 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.