Android - 翻转动画翻转不流畅

标签 android animation flip scaletransform

我想让我的图片水平翻转4次,同时缩小。

我有以下翻转代码:

ObjectAnimator flipAnimation = ObjectAnimator.ofFloat(view, "rotationY", 0.0f, 1440f);
flipAnimation.setDuration(4000);
flipAnimation.start();

我在 scale_down.xml 中有以下代码用于缩小:

<scale
        android:duration="4000"
        android:fromXScale="1"
        android:fromYScale="1"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toXScale="0.1"
        android:toYScale="0.1" >
    </scale>

但是,当我在 eclipse 的模拟器上运行我的应用程序时,翻转图像显示出一种尴尬的效果。从图片中可以看出,有时在翻转时,垂直的一侧比另一侧长,产生拉伸(stretch)效果,这不是我想要的。有什么有助于消除这种影响的吗?

enter image description here enter image description here enter image description here

最佳答案

这种效果称为透视变形。这正是setCameraDistance()用于:

Sets the distance along the Z axis (orthogonal to the X/Y plane on which views are drawn) from the camera to this view. The camera's distance affects 3D transformations, for instance rotations around the X and Y axis. If the rotationX or rotationY properties are changed and this view is large (more than half the size of the screen), it is recommended to always use a camera distance that's greater than the height (X axis rotation) or the width (Y axis rotation) of this view.

The distance of the camera from the view plane can have an affect on the perspective distortion of the view when it is rotated around the x or y axis. For example, a large distance will result in a large viewing angle, and there will not be much perspective distortion of the view as it rotates. A short distance may cause much more perspective distortion upon rotation, and can also result in some drawing artifacts if the rotated view ends up partially behind the camera (which is why the recommendation is to use a distance at least as far as the size of the view, if the view is to be rotated.)

您可能想要修改该值,具体取决于 View 的尺寸和您想要实现的视觉效果。我得到了一个很好的结果:

view.setCameraDistance(10 * view.getWidth());

关于Android - 翻转动画翻转不流畅,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24592731/

相关文章:

java - Sqlite 查询返回 mRowIdColumnIndex 为 -1

android - 动画 Android 窗口和 View

c# - 在 Unity 中转身时翻转敌方 Sprite

jquery - 如何从当前位置翻转 Canvas

android - DDMS 有黑屏

java - Android:edittext - 在字母后键入两个空格用句点替换第一个空格

android - BottomSheetDialog 上方的工具栏

matlab - 如何实现面部 Action 编码系统(FACS)?

jQuery - IE8 中的动画不透明度

用于创建图像镜像并将其与一定量的白色混合的 Python 代码。