2
我在屏幕上移动的ImageView有问题。不幸的是,onTouch Event
只在我触摸ImageView的原始位置时触发。当imageView
正在移动时,它忽略了onTouch事件。总之,原始位置是触发OnTouch事件的唯一方法。在翻译动画期间OnTouchListener不翻译
我在屏幕上移动的ImageView有问题。不幸的是,onTouch Event
只在我触摸ImageView的原始位置时触发。当imageView
正在移动时,它忽略了onTouch事件。总之,原始位置是触发OnTouch事件的唯一方法。在翻译动画期间OnTouchListener不翻译
您应该使用属性动画而不是这些视图动画。处理触摸是使用这种动画的最重要原因之一。
ObjectAnimator anim = ObjectAnimator.ofFloat(view, "translationY", 0f, 100f);
anim.setDuration(1000);
anim.start();
如果您想了解更多信息,请点击此链接: http://developer.android.com/guide/topics/graphics/prop-animation.html
我爱你,伙计。现在,它正在完美运作。只有一件事,我在我的代码中更改了这行 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
我一直在寻找解决方案,只有我意识到翻译动画不会对视图的实际位置做任何事情。 – 2015-04-04 03:39:02