Android Simple animation effect

Source: Internet
Author: User

A1.xml Fade Out effect


<?xml version= "1.0" encoding= "Utf-8"?>


<set xmlns:android= "Http://schemas.android.com/apk/res/android" >


<alpha
android:duration= "500"
Android:fromalpha= "1.0"
Android:toalpha= "0.0"/>
</set>
<!--Fromalpha: Transparency Toalpha at the beginning: Transparency at the end duration: Duration of animation--


A2.xml fade-In effect:


<?xml version= "1.0" encoding= "Utf-8"?>


<set xmlns:android= "Http://schemas.android.com/apk/res/android" >


<alpha
android:duration= "500"
Android:fromalpha= "0.0"
Android:toalpha= "1.0"/>
</set>
Rotate.xml Rotation Effect:


<?xml version= "1.0" encoding= "Utf-8"?>


<set xmlns:android= "Http://schemas.android.com/apk/res/android" >


<rotate
Android:duration= "10000"
android:fromdegrees= "300"
Android:interpolator= "@android: Anim/accelerate_decelerate_interpolator"
android:pivotx= "10%"
Android:pivoty= "100%"
android:todegrees= " -360"/>
</set>
<!--
The angle at which the fromdegrees starts todegrees the angle pivotx,pivoty at the end of the animation relative to the start position of the x and Y coordinates of the object.
50% the midpoint position of the online on the x or y bias coordinates of the object
-


Scale.xml Zoom Effect:


<?xml version= "1.0" encoding= "Utf-8"?>


<set xmlns:android= "Http://schemas.android.com/apk/res/android" >


<scale
Android:duration= "10000"
android:fromxscale= "0.0"
android:fromyscale= "0.0"
Android:interpolator= "@android: Anim/decelerate_interpolator"
android:pivotx= "50%"
Android:pivoty= "50%"
Android:repeatcount= "1"
Android:repeatmode= "Reverse"
android:startoffset= "0"
Android:toxscale= "1.5"
android:toyscale= "1.5"/>
</set>
<!--
interpolator Specifies an animation insert, common with an acceleration reducer accelerate_decelerate_interpolator,
Accelerate the accelerate_interpolator of the insertion device, and decelerate the Decelerate_interpolator.
Fromxscale,fromyscale, the scale of X, y before the start of the animation, 0.0 for not showing, 1.0 for normal size Toxscale,toyscale,
The multiple of the final zoom of the animation, 1.0 for normal size, greater than 1.0 to enlarge the Pivotx,pivoty animation starting position, relative to the screen percentage,
Two all 50% means that the animation starts startoffset from the middle of the screen, the interval of time that the animation executes multiple times, and if it is executed only once, the time is paused before execution.
Unit millisecond duration, an animation effect consumes time, in milliseconds, the smaller the value the faster the animation repeatcount, the animation repeats the count,
The animation will execute the value + 1 times repeatmode, the animation repeats the pattern, the reverse is reversed, and when the first even executes, the animation will be in the opposite direction.
Restart for re-execution, direction unchanged
-


Translate.xml Move Effect:


<?xml version= "1.0" encoding= "Utf-8"?>


<set xmlns:android= "Http://schemas.android.com/apk/res/android" >


<translate
Android:duration= "10000"
Android:fromxdelta= "320"
Android:fromydelta= "480"
Android:toxdelta= "0"
Android:toydelta= "0"/>
</set>
<!--
Fromxdelta,fromydelta animation starts with the x, Y coordinates, and the lower-right corner of the screen is x:320,y:480 Toxdelta,toydelta
coordinates of x, Y at end of animation
-


The animation effect is defined in an XML file in the Anim directory, in a program with animationutils.loadanimation (context context,
int resourcesid) loads into a animation object, performing the Startanimation method of the view that needs to be animated when the animation effect needs to be displayed,
Incoming Animation, you can.
View view = new view (this);
Animation animation=animationutils.loadanimation (this, r.anim.translate);
View.startanimation (animation);
Xxx.addview (view);

Toggle activity can also apply animation effects, after the StartActivity method, execute the Overridependingtransition method,
Two parameters are the animation effect before switching, the animation effect after switching. Overridependingtransition only supports Android 2.0 or later.
StartActivity (Intent);


Overridependingtransition (R.ANIM.A1,R.ANIM.A2);

Android Simple animation effect

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.