android - 在具有深度感知的 z 轴上旋转的 View 之间转换的动画

标签 android layout animation

我正在尝试创建一个动画以在两个 View 之间转换,这两个 View 都是 ExpandableListViews。我想要的外观如下图所示。

我尝试使用 shrink_to_middle 和 grow_from_middle 作为我的 ViewAnimator 的出/入动画 - 它很接近,但不太正确 - 随着动画的发生,我当前的收缩/增长,左右边缘 View 高度相同,不会为动画提供任何深度。

我不确定如何最好地解释我想要的东西,这就是我绘制图像的原因,但不管怎样...我想对动画进行 3D 外观,其中 View 在z 轴。假设我们使用一个简单的 shrink_to_middle 和 grow_from_middle 动画作为起点(它不提供 3-d 外观)。为了提供 3-d 外观,out 动画的右边缘会随着 View 缩小到中间;随着 View 从中间增长,动画中的左边缘会逐渐变大。

图像 1 到 4 将是输出动画(对于 View #1),图像 5-8 将是输入动画(对于 View #2)

animation to transition between views

提前致谢。

编辑: 仅供引用,这是我当前收缩到中间并从中间动画 xml 文件增长

shrink_to_middle.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <scale android:interpolator="@android:anim/linear_interpolator"
        android:fromXScale="1.0" android:toXScale="0.0" android:fromYScale="1.0"
        android:toYScale="1.0" android:fillAfter="false" android:duration="500" />
    <translate android:fromXDelta="0" android:toXDelta="50%"
        android:duration="500" />
</set>

grow_from_middle.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <scale android:interpolator="@android:anim/linear_interpolator"
        android:fromXScale="0.0" android:toXScale="1.0" android:fromYScale="1.0"
        android:toYScale="1.0" android:fillAfter="false" android:startOffset="200"
        android:duration="500" />
    <translate android:fromXDelta="50%" android:toXDelta="0"
        android:startOffset="200" android:duration="500" />
</set>

最佳答案

Rotate3dAnimation 就是答案。它位于示例 SDK 文件夹中。我正在使用 0 到 -90 的动画和 90 到 0 的动画,效果很好。

关于android - 在具有深度感知的 z 轴上旋转的 View 之间转换的动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7705549/

相关文章:

单击带有 okhttp3 请求的按钮时,android 应用程序停止工作

android - XML 中的边距/填充百分比

html - 使用 grid960 在父 div 中封装一系列网格以控制高度

android - 从布局 xml 文件中旋转 ImageView 源

animation - UITextfield 的 contentoffset 上的 UIView.animateWithDuration : It clips the text (Swift)

javascript - 带 Promise 的 jQuery 动画回调仍然触发得太早

javascript - jQuery UI 模式对话框覆盖淡出

android - 如何停止父 Activity 的 Activity ?

安卓蓝牙 : Convert ScanResult timestampNanos to System nanoTime

java - 让 Dexguard 不删除未使用的资源