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 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

Android Animation parsing

Alpha XML fade Out effect

[CPP]View Plaincopy
  1. <?xml version="1.0" encoding="Utf-8"?>
  2. <set xmlns:android="http://schemas.android.com/apk/res/android" >
  3. <alpha
  4. Android:fromalpha="1.0"
  5. android:toalpha="0.0"
  6. android:duration="/> "
  7. </set>
  8. <!--
  9. Fromalpha: Transparency at start
  10. Toalpha: End-of-time transparency
  11. Duration: Animation Duration--

Alpha XML fade-in effect

[CPP]View Plaincopy
  1. <?xml version="1.0" encoding="Utf-8"?>
  2. <set xmlns:android="http://schemas.android.com/apk/res/android" >
  3. <alpha
  4. android:fromalpha="0.0"
  5. Android:toalpha="1.0"
  6. android:duration="/> "
  7. </set>
  8. <!--
  9. Fromalpha: Transparency at start
  10. Toalpha: End-of-time transparency
  11. Duration: Animation Duration--



rotate.xml Rotation effect:

[HTML]View Plaincopy
  1. <? XML version= "1.0" encoding="Utf-8"?>
  2. <set xmlns:android="http://schemas.android.com/apk/res/android">
  3. <rotate
  4. android:interpolator="@android: Anim/accelerate_decelerate_interpolator"
  5. android:fromdegrees="
  6. android:todegrees=" -360"
  7. android:pivotx="10%"
  8. android:pivoty="100%"
  9. android:duration="10000" />
  10. </Set>
  11. <!--
  12. Fromdegrees the angle at which the animation starts
  13. Todegrees the rotation angle of the object at the end of the animation, which means clockwise
  14. The Pivotx property is the start position of the animation relative to the X coordinate of the object
  15. The Pivoty property is the start position of the animation relative to the object's y-coordinate->



scale.xml Zoom Effect:

[CPP]View Plaincopy
  1. <?xml version="1.0" encoding="Utf-8"?>
  2. <set xmlns:android="http://schemas.android.com/apk/res/android" >
  3. <scale
  4. Android:interpolator= "@android: Anim/decelerate_interpolator"
  5. android:fromxscale="0.0"
  6. android:toxscale="1.5"
  7. android:fromyscale="0.0"
  8. android:toyscale="1.5"
  9. android:pivotx="50%"
  10. android:pivoty="50%"
  11. android:startoffset="0"
  12. android:duration="10000"
  13. android:repeatcount="1"
  14. android:repeatmode="reverse"/>
  15. </set>
  16. <!--
  17. Fromxdelta,fromydelta at the beginning of the x, y coordinates, the lower right corner of the screen is the coordinates x:320,y:480
  18. Toxdelta, Toydelta, x, y coordinates at the end of the animation <!--
  19. Interpolator Specifying an animation insert
  20. Common with acceleration reducer accelerate_decelerate_interpolator
  21. Accelerate the accelerate_interpolator of the insertion device,
  22. decelerate the insertion device decelerate_interpolator.
  23. Fromxscale,fromyscale, the scale of X, y before the start of the animation, 0.0 for not showing, 1.0 for normal size
  24. Toxscale,toyscale, the multiple of the final zoom of the animation, 1.0 for normal size, greater than 1.0 magnification
  25. Pivotx, Pivoty animation start position, relative to the screen percentage, two are 50% means the animation starts from the middle of the screen
  26. Startoffset, the interval of time that the animation is executed more than once, which pauses the time before execution,
  27. Unit millisecond duration, the time that the animation effect consumes, the unit milliseconds,
  28. The smaller the value the faster the animation repeatcount, the animation repeats the count, the animation will execute the value + 1 times
  29. Repeatmode, the animation repeats the pattern, the reverse is reversed, and when the first even executes, the animation is in the opposite direction.
  30. Restart for re-execution, no change in direction--





translate.xml Move Effect:

[HTML]View Plaincopy < param name= "wmode" value= "Transparent" >
    1. <? XML version= "1.0" encoding="Utf-8"?>
    2. <set xmlns:android="http://schemas.android.com/apk/res/android">
    3. <translate
    4. android:fromxdelta=" the"
    5. android:toxdelta="0"
    6. android:fromydelta="480"
    7. android:toydelta="0"
    8. android:duration="10000" />
    9. </Set>
    10. <!--
    11. Fromxdelta,fromydelta at the beginning of the x, y coordinates, the lower right corner of the screen is the coordinates x:320,y:480
    12. 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.