【发布时间】:2017-08-18 01:11:32
【问题描述】:
感谢您阅读我的问题。 我的问题只出现在 android 7.0 (Nougat) 中,它发生的是卡片(带有图像视图的片段)当它在动画中旋转时,它突然裁剪了部分图像,看:
Android 7 Nougat 截图
Android 4.4 Kitkat 截图
我正在使用动画(还不是 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