Animation translate, scale, alpha, rotate animation effects

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

1<?xml version="1.0"encoding="Utf-8"?>2<SetXmlns:android="http://schemas.android.com/apk/res/android">3<Alpha4Android:fromalpha="1.0"  5Android:toalpha="0.0"  6android:duration=" -"/>7</Set>8<!--9 Fromalpha: Transparency at StartTen toalpha: End -of-time transparency OneDuration: Animation Duration--
View Code

Alpha XML fade -In effect

1<?xml version="1.0"encoding="Utf-8"?>2<SetXmlns:android="http://schemas.android.com/apk/res/android">3<Alpha4Android:fromalpha="0.0"  5Android:toalpha="1.0"  6android:duration=" -"/>7</Set>8<!--9 Fromalpha: Transparency at StartTen toalpha: End -of-time transparency OneDuration: Animation Duration--
View Code

Scale.xml Zoom effect :

1<?xml version="1.0"encoding="Utf-8"?>2<SetXmlns:android="http://schemas.android.com/apk/res/android">3< Scale4Android:interpolator="@android: Anim/decelerate_interpolator"       5android:fromxscale="0.0"   6android:toxscale="1.5"   7android:fromyscale="0.0"   8android:toyscale="1.5"   9android:pivotx="50%"   Tenandroid:pivoty="50%"    Oneandroid:startoffset="0"    Aandroid:duration="10000"   -Android:repeatcount="1"    -Android:repeatmode="Reverse"/> the</Set> -  -<!-- -x, y coordinates at the beginning of the Fromxdelta,fromydelta, and the coordinates in the lower right corner of the screen are ×: theY:480  +Toxdelta, Toydelta, x, y coordinates at the end of the animation <!-- - Interpolator Specifying an animation insert + common with acceleration reducer accelerate_decelerate_interpolator A accelerate the accelerate_interpolator of the insertion device, at decelerate the insertion device decelerate_interpolator.  -Fromxscale,fromyscale, the scale of X, y before the animation starts,0.0 is not displayed,1. 0 for normal size -Toxscale,toyscale, the multiple of the final zoom of the animation,1. 0 is normal size, greater than 1.0 magnification -Pivotx, Pivoty animation starting position, relative to the screen percentage, two are 50%indicates that the animation starts from the middle of the screen - Startoffset, the interval of time that the animation is executed more than once, which pauses the time before execution , - unit millisecond duration, the time that the animation effect consumes, the unit milliseconds, inThe smaller the value, the faster the animation repeatcount, the animation repeats the count, and the animation will execute the value +1 plays - Repeatmode, the animation repeats the pattern, the reverse is reversed, and when the first even executes, the animation is in the opposite direction.  toRestart for re-execution, no change in direction--
View Code

translate.xml Move effect :

1<?xml version="1.0"encoding="Utf-8"?>2<SetXmlns:android="http://schemas.android.com/apk/res/android">3<Translate4Android:fromxdelta=" the" 5Android:toxdelta="0" 6Android:fromydelta="480" 7Android:toydelta="0" 8android:duration="10000"/>9</Set>Ten<!-- Onex, y coordinates at the beginning of the Fromxdelta,fromydelta, and the coordinates in the lower right corner of the screen are ×: theY:480  AToxdelta, Toydelta x, y coordinates at the end of the animation
View Code

rotate.xml Rotation effect:

1 <?xml version="1.0"Encoding="Utf-8"?>2 <Set xmlns:android="Http://schemas.android.com/apk/res/android">3 <Rotate4 android:interpolator="@android: Anim/accelerate_decelerate_interpolator"5 android:fromdegrees="300"6 android:todegrees="-360"7 android:pivotx= "10%"  8 Android:pivoty=100%  " 9 Android:duration=" 1000010 </< Span style= "color: #0000ff;" >set> 11 <!--12 13  todegrees the rotation angle of the object at the end of the animation, which represents the clockwise Span style= "color: #008080;" >14 15 Pivoty property is the starting position of the animation relative to the object's y-coordinate             
View Code

Animation translate, scale, alpha, rotate animation effects

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.