【发布时间】:2014-12-14 21:42:20
【问题描述】:
我正在使用 ObjectAnimator 在 Android (API 19) 中为 ImageView 制作动画。我一切正常,它在 Galaxy S3 上完美显示,但在我的 Nexus 7(2013 WiFi 型号)上却出现问题。
目标是使用rotateY 让图像围绕其 Y 轴进行完整的 360° 旋转。但是,在 Nexus 7 上,在 75° 和 105° 之间,图像会消失。我的drawable是从PNG创建的,相关代码如下。
查看:
<ImageView
android:id="@+id/login_logo"
android:layout_width="match_parent"
android:layout_height="120dp"
android:layout_marginTop="30dp"
android:src="@drawable/mimo_logo"/>
开始动画:
ImageView image = (ImageView) findViewById(R.id.login_logo);
Animator anim = AnimatorInflater.loadAnimator(context, R.animator.flipping);
anim.setTarget(image);
anim.start();
还有动画本身:
<?xml version="1.0" encoding="utf-8"?>
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="3000"
android:propertyName="rotationY"
android:repeatCount="-1"
android:valueFrom="0"
android:valueTo="360" />
我会努力获取实际问题的 GIF,但有人知道为什么 Nexus 7 会出现问题吗?
编辑:
这是它的样子(使用adb shell screenrecord 录制):
【问题讨论】:
-
所以它消失了,因为系统不知道它的背面是什么样子
-
一旦它旋转超过 105°,它看起来完全没有问题(显示背面,图像向后)。只有当图像实际上“处于边缘”时,我才会遇到问题
-
您是否尝试增加持续时间以查看插值步骤是否真的很棘手?将其增加到 10 或 20 秒,看看外观是否发生变化或问题是否仍然存在。
-
刚刚确认即使持续 30 秒,图像仍然会消失,并且仍然只在 Nexus 7 上。但我确实意识到,S3 运行的是 Android 4.3,而 Nexus 7 运行的是 5.0.1 .我开始寻找其他运行 Lollipop 的设备来检查它是否是 Lollipop 特定的。
-
接下来,刚刚在运行 Lollipop 的 2012 Nexus 7 (WiFi) 上进行了测试,旋转显示完美。
标签: android imageview objectanimator