2015-04-04 74 views

回答

2

您应该使用属性动画而不是这些视图动画。处理触摸是使用这种动画的最重要原因之一。

ObjectAnimator anim = ObjectAnimator.ofFloat(view, "translationY", 0f, 100f); 
anim.setDuration(1000); 
anim.start(); 

如果您想了解更多信息,请点击此链接: http://developer.android.com/guide/topics/graphics/prop-animation.html

+0

我爱你,伙计。现在,它正在完美运作。只有一件事,我在我的代码中更改了这行 TranslateAnimation animation = new TranslateAnimation(0.0f,0.0f, 0.0f,-100.0f); 至: ObjectAnimator animation = ObjectAnimator.ofFloat(myImageView,“translationY”,0f,-100f); – 2015-04-04 03:31:10

+0

我一直在寻找解决方案,只有我意识到翻译动画不会对视图的实际位置做任何事情。 – 2015-04-04 03:39:02