1

我有 LinearLayout,它有 1) 视图和 2) 有一个手势检测器。我的问题是,当我想在线性布局上做一个投掷手势时,如果我的手指碰到任何视图,它会抛出一个 MotionEvent.ACTION_CANCEL 这将阻止 onFling() 回调触发。

我不能真正禁用对这些前景视图的触摸,因为它们是启动 Intents 导航的一部分。

谢谢,-毫升

4

2 回答 2

0

听起来好像您没有将 GestureOverlayView 作为布局中的根元素?

简短的例子:

<android.gesture.GestureOverlayView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/gestures"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"

    android:gestureStrokeType="multiple"
    android:eventsInterceptionEnabled="true"
    android:orientation="vertical">

    <ListView
        android:id="@android:id/list"  
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"  />

</android.gesture.GestureOverlayView>

见这里:http: //developer.android.com/resources/articles/gestures.html

于 2012-05-08T18:52:25.163 回答
0

试着看看 ViewPager 里面是怎么做的。 http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.0.3_r1/android/support/v4/view/ViewPager.java#ViewPager.onInterceptTouchEvent%28android。 view.MotionEvent%29

您需要创建您的 LinearLayout(通过简单地扩展 Android 的 LinearLayout)并覆盖 onInterceptTouchEvent。这在孩子之前被调用,如果它返回真正的父母窃取孩子的触摸。 http://developer.android.com/reference/android/view/ViewGroup.html#onInterceptTouchEvent(android.view.MotionEvent )

于 2012-05-08T18:57:56.190 回答