大家好我已经通过遵循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上遵循的教程。
答案 0 :(得分:0)
FInally找到了一种改变旋转轴的方法。问题是我在哪里看上面的方法不是改变旋转轴的地方只是改变了下面的方法
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;
}