1

嗨,伙计们,我已经通过遵循 android 翻转动画教程来为图像设置动画,但是我遇到了这个问题,我尝试像在应用程序中那样为蝴蝶设置动画,ibutterfly并且我正在使用这种方法来应用转换

protected void applyTransformation(float interpolatedTime, Transformation t) {
    final float fromDegrees = mFromDegrees;
    float degrees = fromDegrees
            + ((mToDegrees - fromDegrees) * interpolatedTime);

    final float centerX = mCenterX;
    final float centerY = mCenterY;
    final Camera camera = mCamera;

    final Matrix matrix = t.getMatrix();

    camera.save();

    camera.rotateY(degrees);



    camera.getMatrix(matrix);
    camera.restore();

    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);

    matrix.preScale(scaleType.getScale(scale, interpolatedTime),
            scaleType.getScale(scale, interpolatedTime), centerX, centerY);

}

我遇到的问题是图像从中间点旋转,但我需要将旋转轴更改为左角有没有办法做到这一点,我尝试了我所知道的一切,但我无法做到,如果有人可以帮助我我将非常感谢

这是我在Google Code上遵循的教程。

4

1 回答 1

0

终于找到了改变旋转轴的方法。问题是我在哪里看上面的方法不是改变旋转轴的地方只需要改变下面的方法

public static Animation[] flipAnimation(
            final View fromView,
            final View toView,
            FlipDirection flipDirection,
            long duration, Interpolator interpolator) {
        Animation[] result = new Animation[2];
        float centerX;
        float centerY;

        centerX = 0.0f; // Simpliy had to change the centerX value here 
        centerY = fromView.getHeight(); 

        Animation outFlip = new FlipAnimation(
                flipDirection.getStartDegreeForFirstView(),
                flipDirection.getEndDegreeForFirstView(), centerX, centerY,
                FlipAnimation.SCALE_DEFAULT,
                FlipAnimation.ScaleUpDownEnum.SCALE_NONE);
        outFlip.setDuration(duration);
        outFlip.setFillAfter(true);
        outFlip.setInterpolator(interpolator == null ? new AccelerateInterpolator()
                : interpolator);

        AnimationSet outAnimation = new AnimationSet(true);
        outAnimation.addAnimation(outFlip);
        result[0] = outAnimation;

        // Uncomment the following if toView has its layout established (not the
        // case if using ViewFlipper and on first show)
        // centerX = toView.getWidth() / 2.0f;
        // centerY = toView.getHeight() / 2.0f;

        Animation inFlip = new FlipAnimation(
                flipDirection.getStartDegreeForSecondView(),
                flipDirection.getEndDegreeForSecondView(), centerX, centerY,
                FlipAnimation.SCALE_DEFAULT,
                FlipAnimation.ScaleUpDownEnum.SCALE_NONE);
        inFlip.setDuration(duration);
        inFlip.setFillAfter(true);
        inFlip.setInterpolator(interpolator == null ? new AccelerateInterpolator()
                : interpolator);
        inFlip.setStartOffset(duration);

        AnimationSet inAnimation = new AnimationSet(true);
        inAnimation.addAnimation(inFlip);
        result[1] = inAnimation;

        return result;

    }
于 2013-09-05T10:08:51.063 回答