View disappears near end of RotationY animation

I am trying to put together a smooth animation in which the view, which occupies most of the screen, rotates to open another view on the back side:

rotatingView.animate().rotationY(90) .setDuration(250) .setInterpolator(new AccelerateInterpolator()) .withEndAction( /* Runnable that sets up the rear side of the view, then rotates Y another 90 degrees */); 

The problem is that about 80% of the path of this animation disappears. The species does not appear again until approximately 20% of the path in the second half. In other words, it disappears at 11 o’clock and reappears at 1 o’clock. Why is this?

+4
android animation android-animation
source share
1 answer

I finally came across an answer to this type of problem. Use setCameraDistance() , but note that :

The distance is expressed in "depth pixels". The default distance depends on the density of the screen. For example, on a medium-density display, the default distance is 1280. On a high-density display, the default value is 1920.

So, to "raise" the camera to a point where the nearest viewing edge does not crop it, set the distance to several times "default". In my case, with multiple tablet screens, a value of 4000f was required. For more details see the link for a more detailed calculation of the setCameraDistance() parameters.

You can combine setCameraDistance() with clipToPadding="false" and clipChildren="false" in your XML file; they control the camouflage of one species by another.

In addition, I suspect YMMV in different versions and providers of Android.

0
source share

All Articles