从未调用过GLSurfaceView OnTouchEvent

时间:2015-08-11 17:34:32

标签: android opengl-es xamarin gesture glsurfaceview

在我的Xamarin Android应用程序中,我创建了一个带有自定义GLSurfaceView的Activity。布局如下:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:local="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="20dp"
        android:text="Hi! I am model viewer!" />
    <test.ui.droid.controls.ModelViewerGLSurfaceView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" />
</LinearLayout>

我的自定义ModelViewerGLSurfaceView(派生自GLSurfaceView)是OpenGL渲染所必需的,并且工作正常。

现在我想添加手势识别功能。为了做到这一点,我在ModelViewerGLSurfaceView中重写了OnTouchEvent,但无论我做什么,都不会调用此函数。

但是,当我在父Activity上覆盖OnTouchEvent时,它可以正常工作。

为什么永远不会为我的GLSurfaceView调用OnTouchEvent?

1 个答案:

答案 0 :(得分:0)

你有没有忘记注册onTouchListener?

您需要在视图上调用setOnTouchListener来注册回调。

http://developer.android.com/reference/android/view/View.html#setOnTouchListener(android.view.View.OnTouchListener)