【发布时间】:2014-07-31 21:58:42
【问题描述】:
我正在制作一个包含大量 ImageViews 的应用程序,我需要在其中一些中附加一个触摸监听器。在执行此操作时,我遇到了一个问题。如果指针在带有触摸侦听器的ImageView 的位置被按住并且即将产生滚动事件,则Views 和ScrollView 之间似乎存在战斗场景,在 w/c 中该事件实际上已发生,并且在 w/c 中该事件应该属于该事件。 屏幕快速滚动然后返回第一个指针被触摸的地方,因此这意味着这是一种不受欢迎的行为。
在ImageView 中设置onTouchListener 会使滚动变得不安且不需要,如何防止ImageView 在滚动时接收到触摸事件?
部分代码
布局:act_map_view.xml
<?xml version="1.0" encoding="utf-8"?>
<com.nkraft.mobiletomblocator.CustomVScroll
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/vScroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none" >
<com.nkraft.mobiletomblocator.CustomHScroll
android:id="@+id/hScroll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollbars="none" >
<com.nkraft.mobiletomblocator.CustomGridLayout
android:id="@+id/map_grid"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</com.nkraft.mobiletomblocator.CustomGridLayout>
</com.nkraft.mobiletomblocator.CustomHScroll>
</com.nkraft.mobiletomblocator.CustomVScroll>
注意事项:
-
GridLayout在运行时由ImageViews 填充。 - 我自定义了我的水平和垂直
ScrollView,以便我可以同时在两个方向上滚动,即对角线滚动
【问题讨论】:
标签: android event-handling scroll imageview