Android implementation Animation class

Source: Internet
Author: User

Android JDK provides us with 4 animation effects, namely: Alphaanimation,rotateanimation, Scaleanimation, Translateanimation. Today I would like to explain the animation effect of translateanimation. I was also in the animation of a mobile image of the project, encountered some problems. On the internet to check a lot of information, for several days. Finally understand how to use this translateanimation, recorded in this article, so that later forgotten can be consulted.


The translateanimation is a moving animation effect. It has three constructors, namely:


1.public translateanimation (Context context,attributeset attrs) Skip


2.public translateanimation (float fromxdelta, float toxdelta, float fromydelta, float toydelta)


This is one of our most common construction methods,


Float Fromxdelta: This parameter represents the difference between the point at which the animation starts and the current view x coordinate;


Float Toxdelta, which represents the difference between the point at which the animation ends and the current view x coordinate;


Float Fromydelta, which represents the difference between the starting point of the animation and the current view y-coordinate;


float Toydelta) This parameter represents the difference between the point at which the animation starts and the current view y-coordinate;


If the view is in a (x, y) point then the animation is moved from point B (X+fromxdelta, Y+fromydelta) to point C (X+toxdelta,y+toydelta).






3.public translateanimation (int fromxtype, float fromxvalue, int toxtype, float toxvalue, int fromytype, float Fromyvalu e, int toytype, float toyvalue)


Fromxtype: The first parameter is a reference to the value in the x-axis direction (Animation.absolute, Animation.relative_to_self,or animation.relative_to_parent);


Fromxvalue: The second parameter is the starting value of the first parameter type;


Toxtype,toxvalue: The third parameter and the fourth parameter are the end references and corresponding values in the x-axis direction;


The following four parameters are not explained. If you select Animation.absolute all, it is actually the second constructor.


Take the x-axis as an example to describe the relationship between references and corresponding values:


If the selection reference is Animation.absolute, then the corresponding value should be a specific coordinate value, such as 100 to 300, which refers to absolute screen pixel units


If the selection reference is animation.relative_to_self or animation.relative_to_parent refers to a relative to itself or to a parent control, the corresponding value should be interpreted as relative to itself or the number of times or percent of the parent control. The multi-test parameter is clear.

Android implementation Animation class

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.