ViewPropertyAnimatorCompat.translationY呈现不同的屏幕尺寸

时间:2016-04-03 16:00:51

标签: android android-animation

可能答案非常简单,但我是Android Animations的新手。我在Nexus 5设备中使用以下代码正常工作(使用4.95英寸1080x1920显示屏):

ViewCompat.animate(imageView)
                .translationY(-400)
                .alpha(1)
                .setStartDelay(200)
                .setDuration(800).setInterpolator(
                new DecelerateInterpolator(1.2f)).start();

动画将图像转换为400点(像素?),并在我想要的位置结束。 问题是当我的应用程序在模拟器Nexus(800x1280)7和Nexus 10(2560x1600)上运行时,在这两种情况下,Y轴上的移动大小在它们之间是不同的,并且相对于手机也是不同的,例如,我最终在3个设备中转换了400分,但在这三种情况下运动是不同的。我的问题是如何使这个运动对所有屏幕尺寸(只有一个数字)相等,因此不必在translationY(var)方法中使用变量?还是我必须考虑到3种可能的情况而使用变量?提前谢谢!

0 个答案:

没有答案