【问题标题】:Card flip Animation not looking good on Android 7 Nougat卡片翻转动画在 Android 7 Nougat 上看起来不太好
【发布时间】:2017-08-18 01:11:32
【问题描述】:

感谢您阅读我的问题。 我的问题只出现在 android 7.0 (Nougat) 中,它发生的是卡片(带有图像视图的片段)当它在动画中旋转时,它突然裁剪了部分图像,看:

Android 7 Nougat 截图

Card in rotation

Android 4.4 Kitkat 截图

Card in rotation

我正在使用动画(还不是 objectAnimator),这是我的代码:

@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    // Angle around the y-axis of the rotation at the given time
    // calculated both in radians and degrees.
    final double radians = Math.PI * interpolatedTime;
    float degrees = (float) (180.0 * radians / Math.PI);

    Log.d(LOG_TAG," "+interpolatedTime);

    // Once we reach the midpoint in the animation, we need to hide the
    // source view and show the destination view. We also need to change
    // the angle by 180 degrees so that the destination does not come in
    // flipped around
    if (interpolatedTime >= 0.5f) {
        degrees -= 180.f;
        fromView.setVisibility(View.GONE);
        toView.setVisibility(View.VISIBLE);

    }

    if (forward)
        degrees = -degrees; //determines direction of rotation when flip begins


    //computing
    final Matrix matrix = t.getMatrix();
    camera.save();
    camera.translate(0, 0, Math.abs(degrees) * 3f);
    camera.rotateY(degrees);
    camera.getMatrix(matrix);
    camera.restore();
    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}

非常感谢您分享您的想法。 :)

【问题讨论】:

  • 即使我使用 objectAnimator。它裁剪了一点,但是当我在两个基本图像(另一个)中使用它时效果很好。我认为在我的卡片中,问题在于它们包含更多视图,或者因为它们使用 SimpleDraweeView 而不是 imageView

标签: android animation matrix android-7.0-nougat card-flip


【解决方案1】:

阅读https://developer.android.com/reference/android/view/View.html#setCameraDistance(float)

您必须设置相机距离。 我知道这个问题很老了,但我希望这对某人有所帮助。

【讨论】:

  • 欢迎提供解决方案链接,但请确保您的答案在没有它的情况下有用:add context around the link 这样您的其他用户就会知道它是什么以及为什么会出现,然后引用最相关的您链接到的页面的一部分,以防目标页面不可用。 Answers that are little more than a link may be deleted.
  • 感谢您的建议,在这种情况下,我应该复制并粘贴链接上的所有内容吗?因为我认为不存在可以提供帮助的单引号。
猜你喜欢
  • 1970-01-01
  • 2013-04-08
  • 2013-11-22
  • 2013-12-21
  • 2014-03-03
  • 1970-01-01
  • 1970-01-01
  • 2018-02-17
相关资源
最近更新 更多