Android animation—tweened animation

Frame animation simulates animation effects by continuously playing pictures, while tween animation developers only need to specify the animation start and animation end "key frames", while the "intermediate frames" of animation changes are calculated and completed by the system!

Insert image description here

1. Classification of tween animation and Interpolator

The tween animation effects supported by Andoird include the following five types, or four types. The fifth type is just a combination of the previous ones.

  • AlphaAnimation: Transparency gradient effect, specify the start and end transparency when creating, as well as the duration of the animation, the transparency range (0,1), 0 is completely transparent, 1 is completely opaque; corresponds to the <alpha /> tag !
  • ScaleAnimation : Scale gradient effect. When creating, you need to specify the start and end scaling ratios, as well as the scaling reference point, and the duration of the animation; corresponds to the < scale /> tag!
  • TranslateAnimation : displacement gradient effect, specify the starting and ending positions when creating, and specify the duration of the animation; corresponds to the < translate /> tag!
  • RotateAnimation : Rotation gradient effect. When creating, specify the starting and ending rotation angles of the animation, as well as the animation duration and the axis of rotation; corresponds to the < rotate /> tag
  • AnimationSet : Combination gradient is a combination of the previous gradients, corresponding to the < set /> tag

Before we start explaining the usage of various animations, we first need to explain something: Interpolator

Used to control the changing speed of animation, it can be understood as an animation renderer. Of course, we can also implement the Interpolator interface ourselves to control the changing speed of animation. Android has provided us with five optional implementation classes:

  • LinearInterpolator : animation changes at a uniform speed
  • AccelerateInterpolator : Changes the speed slower where the animation starts, then starts to speed up
  • AccelerateDecelerateInterpolator : Changes slowly at the beginning and end of the animation, and accelerates in the middle
  • CycleInterpolator : The animation loops for a specific number of times, and the changing speed changes according to a sinusoidal curve: Math.sin(2 * mCycles * Math.PI * input)
  • DecelerateInterpolator : Changes faster where the animation starts, then starts to slow down
  • AnticipateInterpolator : Reverse, first change a section in the opposite direction and then speed up the playback
  • AnticipateOvershootInterpolator : Starts backwards and then throws forward a certain value and returns to the final value.
  • BounceInterpolator : Jump. The value will jump when it reaches the target value. For example, the target value is 100, and the following values ​​may be 85, 77, 70, 80, 90, 100.
  • OvershottInterpolator : rebound, finally exceed the target value and then slowly change to the target value

2. Detailed explanation of various animations

The android:duration here is the duration of the animation, the unit is milliseconds

1)Alph

Guess you like

Origin blog.csdn.net/m0_70748458/article/details/130362643