Interpolator detailed explanation

The relevant attributes of the current animation interpolator are as follows:

1. AccelerateDecelerateInterpolator (first slow, then fast and then slow)

2. Accelerate Interpolator (first slow and then fast)

3. AnticipateInterpolator forward interpolator (first run back a little, then speed up and run forward)

4. AnticipateOvershootInterpolator forward and backward interpolator (first run back a bit, then run back a bit, and then back to the end)

5. BounceInterpolator (bounce a few times at the end of the animation, if it is moving vertically downwards, it will be the effect of a few bounces under the glass ball)

6. The CycleInterpolator interpolator cycle (path specified by the specified time (or offset) of 1 / 4 , the shift is performed again, and then take the opposite reverse specified track 1 / 2 times, then the specified path direction of finish remaining 1 / 4 time, and finally back to the origin if: the default is to have a run east from the origin 100 yards east it will first run. 100 m west and run 200 is rice, and then Run 100 meters east to return to the origin. The number of cycles can be specified in the code)

7. DecelerateInterpolator (fast first and slow later)

8. LinearInterpolator (uniform speed)

9. OvershootInterpolator exceeds the interpolator (run forward until it crosses the boundary, and then run back)

10. FastOutLinearInInterpolator MaterialDesign based on Bezier curve interpolator effect: Slowly and quickly in turn

11. FastOutSlowInInterpolator MaterialDesign based on Bezier curve interpolator effect: Slow and fast in turn

12. LinearOutSlowInInterpolator MaterialDesign based on Bezier curve interpolator effect: in turn fast and slowly

Let me add the understanding of Bezier curve: general vector graphics software uses it to accurately draw the curve. The Bezier curve is composed of line segments and nodes . The nodes are draggable fulcrums, and the line segments are like stretchable rubber bands. We are drawing The "pen tool" seen on the tool (PS) is used to make this vector curve.

There are two methods used: 1. It is quoted in the layout file 2. It is implemented by code

method one:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:fillAfter="true"
    android:interpolator="@android:anim/linear_interpolator">//对当前动画设置插补器
    <translate
        android:duration="2000"
        android:fromXDelta="50%"
        android:fromYDelta="0%"
        android:interpolator="@android:anim/linear_interpolator"// 对当前节点设置插补器
        android:toXDelta="500%"
        android:toYDelta="0%" />
</set>
Method Two:

Animation mAnimation = AnimationUtils.loadAnimation(this, R.anim.xxx);//引用动画文件
mAnimation.setInterpolator(new LinearInterpolator());//代码设置插补器
view.startAnimation(mAnimation);


ok, that's it.


Guess you like

Origin blog.csdn.net/xifei66/article/details/57997947