GestureOverlayView阻止触摸事件

时间:2012-11-02 12:45:06

标签: android events touch

我希望为我的手势创建一个自定义视图,我希望自己画出来。

但是我没有得到触摸事件,或者我没有得到它们而且没有GestureOverlayView。

你能帮助我,让我们两个都搞定所有的触摸事件吗?

2 个答案:

答案 0 :(得分:-1)

您可以像这样覆盖onTouchEvent方法

@Override
public boolean onTouchEvent(MotionEvent event) {
// Your code here
}

答案 1 :(得分:-1)

我认为你可能在做我以前做的一个愚蠢的错误。不要将gestureOverlayView平行地放在想要触摸的视图上,而是将这些视图作为gestureOverLayView的子视图。

你不该做什么

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
        <android.gesture.GestureOverlayView
            android:id="@+id/gOverlay"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:eventsInterceptionEnabled="true"
            android:fadeOffset="1000"
            android:gestureColor="@color/gesture_color"
            android:gestureStrokeType="multiple"
            android:uncertainGestureColor="@color/gesture_color" >
        </android.gesture.GestureOverlayView>
        <LinearLayout
            android:id="@+id/customtab"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal"
            android:weightSum="3" >
        </LinearLayout>
    </RelativeLayout>

你应该做什么..

    <android.gesture.GestureOverlayView
        android:id="@+id/gOverlay"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:eventsInterceptionEnabled="true"
        android:fadeOffset="1000"
        android:gestureColor="@color/gesture_color"
        android:gestureStrokeType="multiple"
        android:uncertainGestureColor="@color/gesture_color" >
        <LinearLayout
            android:id="@+id/customtab"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:weightSum="3" >
        </LinearLayout>
    </android.gesture.GestureOverlayView>