2015-04-04 90 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