android - OnTouchListener 在 TranslationAnimation 期间不进行翻译

标签 android imageview ontouchlistener

我遇到了在屏幕上移动的 ImageView 的问题。不幸的是,只有当我触摸 ImageView 的原始位置时才会触发 onTouch 事件。当imageView移动时,它会忽略onTouch事件。综上所述,原始位置是触发OnTouch事件的唯一途径。

最佳答案

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

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

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

关于android - OnTouchListener 在 TranslationAnimation 期间不进行翻译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29442251/

相关文章:

swift - 如何在 UITableView Cell 中为 ImageView 添加尺寸和位置?

Android:无法将矩阵 ImageView 放置在屏幕中央?

android - onTouch 提供奇怪的触摸点 Android

android - 无法在 View 上检测到触摸事件并在父 View 上检测到点击事件

android - 我的华为杀死了我的 wakelock android 应用程序

android - 在 React Native 中设置原生 UISplitViewController

java - 为什么这两个对象为空?

android - 如何为 ImageView 赋予六边形形状

android - 如何检测按钮背景资源(可绘制)android?

java - 如何在不使用循环器和处理程序的情况下在特定线程中调度任务?