0

thank you for reading my question. The problem I have only occurs in android 7.0 (Nougat) and what it's happening is that the card (a fragment with Image views) when it rotates in the animation, it suddenly crops part of the image, Look:

Android 7 Nougat Screenshoot

Card in rotation

Android 4.4 Kitkat Screenshoot

Card in rotation

I'm using Animation (not objectAnimator yet), Here's my code:

@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);
}

Thank you so much for sharing your ideas. :)

  • Even when I use objectAnimator. It crops a little bit, but I when I use in two basic images (another ones) it work well. I think that in my cards the problem would be that they contain more views or because they use SimpleDraweeView instead of imageView – Carlos Chávez Mar 25 '17 at 16:44

1 Answers1

0

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

You have to set the camera distance. I know that this question is old, but I hope that will help somebody.

barotia
  • 428
  • 4
  • 12
  • A link to a solution is welcome, but please ensure your answer is useful without it: [add context around the link](//meta.stackexchange.com/a/8259) so your fellow users will have some idea what it is and why it’s there, then quote the most relevant part of the page you're linking to in case the target page is unavailable. [Answers that are little more than a link may be deleted.](//stackoverflow.com/help/deleted-answers) – LW001 Nov 17 '17 at 22:52
  • Thanks for advice, in this case should I copy and paste all of the content on the link? Because I think that there is not exists a single quote that can be helpful. – barotia Nov 21 '17 at 11:11