关于AnimationSet.addAnimation()的Android谜题

时间:2016-09-14 16:55:32

标签: android

我是中国人,英语很差,我希望以下描述不会让你感到困惑...... 第一个:

animationSet.addAnimation(animation3D);
animationSet.addAnimation(animationTranslate);

第二个:

 animationSet.addAnimation(animationTranslate);
 animationSet.addAnimation(animation3D);

我发现它们不同,第一个是平滑但第二个不是。

animation3D的代码是:

public class ThreeDRotateAnimation extends Animation {
int centerX, centerY;
Camera camera = new Camera();

@Override
public void initialize(int width, int height, int parentWidth,
                       int parentHeight) {
    super.initialize(width, height, parentWidth, parentHeight);
    centerX = width / 2;
    centerY = height / 2;
    setDuration(500);
    setInterpolator(new LinearInterpolator());
}

@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    final Matrix matrix = t.getMatrix();
    camera.save();
    camera.rotateY(360 * interpolatedTime);
    camera.getMatrix(matrix);
    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
    camera.restore();
}

}

animationTranslate的代码非常简单:

<translate
xmlns:android="http://schemas.android.com/apk/res/android"
android:fromYDelta="-50%p"
android:interpolator="@android:anim/accelerate_interpolator"
android:toYDelta="0%"/>

但我真的不知道为什么他们不一样? addAnimation的顺序是否会导致不同的结果? 我真的需要你的帮助!!!

0 个答案:

没有答案
相关问题