In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail what knowledge about Android animation, the editor thinks it is very practical, so share it for you to do a reference, I hope you can get something after reading this article.
The animation about Android includes the Property Animator after View Animation,3.0 before 3.0and the newly added (Touch feedback (touch feedback) Reveal effect (revealing effect) Activity transitions (Activity conversion effect) Curved motion (curvilinear motion) View state changes (view state change) Animate Vector Drawables (paintable vector animation).
The details of several animations are as follows:
1. View Animation:
The first kind is Tween animation, which is to produce animation effect by constantly changing the image of the objects in the scene.
The second category is Frame animation, that is, sequential playback of pre-made images, which is similar to the principle of gif pictures.
Let's talk about Tweene Animations.
Main categories:
Animation animation
AlphaAnimation gradient transparency
OtateAnimation screen rotation
ScaleAnimation gradient size Scal
RanslateAnimation position shift
AnimationSet Animation Collection
Take a custom View as an example, the View is simple and there is only one image on the screen. Now we are going to implement various Tween animation effects on the entire View.
1) AlphaAnimation implementation code:
/ / initialize Animation alphaAnimation = new AlphaAnimation (0.1f, 1.0F); / / set animation time alphaAnimation.setDuration (3000); this.startAnimation (alphaAnimation)
The first parameter of the AlphaAnimation class, fromAlpha, represents the transparency at the beginning of the animation, and the second parameter, toAlpha, represents the transparency at the end of the animation. SetDuration is used to set the duration of the animation.
FromAlpha, toAlpha attribute description: 0 is completely transparent, 1 is completely opaque, and above is a number of float data types between 0. 0 and 1. 0
2) RotateAnimation implementation code:
Animation rotateAnimation = new RotateAnimation (0f, 360f); rotateAnimation.setDuration (1000); this.startAnimation (rotateAnimation)
The first parameter fromDegrees of the RotateAnimation class represents the angle at the beginning of the animation, and the second parameter toDegrees represents the angle at the end of the animation. In addition, you can also set the scaling modes pivotXType and pivotYType. The fromDegrees and toDegrees attribute values of the stretching animation relative to the starting position of the XMagi y coordinates, such as pivotXValue, pivotYValue, and so on, indicate that it shrinks to no 1.0, which means that the normal non-stretching value is less than 1.0, which means that the shrinking value is greater than 1.0, indicating magnification.
When the angle is negative-- it rotates counterclockwise.
When the angle is positive-- it rotates clockwise.
(negative from--to positive: rotate clockwise)
(negative from--to: rotate counterclockwise)
(positive from--to: rotate clockwise)
(positive from--to negative: rotate counterclockwise)
PivotX, pivotY attribute value description: take the value from 0% Murray 100%, 50% is the midpoint position on the X or Y coordinates of the object
3) ScaleAnimation implementation code:
/ / initialize Animation scaleAnimation = new ScaleAnimation (0.1fMagne 1.0f, 0.1fMagol 1.0f); / / set animation time scaleAnimation.setDuration (500); this.startAnimation (scaleAnimation)
In the ScaleAnimation class
The first parameter fromX and the second parameter toX: the expansion dimensions on the X coordinates at the beginning and end of the animation, respectively.
The third parameter fromY and the fourth parameter toY: the expansion dimensions on the Y coordinates at the beginning and end of the animation, respectively.
In addition, you can also set the stretching mode pivotXType, pivotYType, the starting position of the stretching animation relative to the XMagi y coordinates, pivotXValue, pivotYValue, and so on.
4) TranslateAnimation implementation code:
/ / initialize nimation translateAnimation = new TranslateAnimation (0.1fMagne 100.0f, 0.1fMagne 100.0f); / / set animation time translateAnimation.setDuration (1000); this.startAnimation (translateAnimation)
TranslateAnimation class
The first parameter fromXDelta and the second parameter toXDelta are the X coordinates at the beginning and end of the animation, respectively.
The third parameter fromYDelta and the fourth parameter toYDelta are the Y coordinates at the beginning and end of the animation, respectively.
5) AnimationSet implementation code:
/ / initialize Translate animation translateAnimation = new TranslateAnimation (0.1f translateAnimation 100.0f, 0.1f pen 100.0f); / / initialize Alpha animation alphaAnimation = new AlphaAnimation (0.1f, 1.0f); / / Animation set AnimationSet set = new AnimationSet (true); set.addAnimation (translateAnimation); set.addAnimation (alphaAnimation) / / set animation time (for each animation) set.setDuration (1000); this.startAnimation (set)
6) Interpolator
Used to modify the rate of an animation process, you can define a variety of nonlinear change functions, such as acceleration, deceleration and so on.
All interpolators in Android are subclasses of Interpolator, and you can refer to different interpolators through the android:interpolator property. Here are several kinds of interpolation
You can use them in the following ways:
Custom interpolator
If you are not satisfied with the interpolator provided by the system, we can create an interpolator resource to modify the properties of the interpolator, such as changing the acceleration rate of AnticipateInterpolator, adjusting the number of cycles of CycleInterpolator, etc. To accomplish this requirement, we need to create a XML resource file, put it under / res/anim, and then reference it in the animation element. Let's first take a look at several common properties that the interpolator can adjust:
Android:factor floating-point value, acceleration rate, default is 1
Android:tension floating point value, the number of tension and tension at which the starting point retreats. Default is 2.
Android:tension is the same as android:extraTension floating-point value, multiple of pulling force. Default is 1.5 (2 * 1.5).
Android:cycles int, the number of loops. Default is 1.
Android:factor floating point value, the rate of deceleration. Default is 1.
Floating-point value, tension and tension beyond the end point. Default is 2.
For example: res/anim/my_overshoot_interpolator.xml:
This animation XML will apply the interpolator:
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.