简体   繁体   中英

GLSurfaceView OnTouchEvent never called

In my Xamarin Android application I created an Activity with custom GLSurfaceView on it. The layout is following:

<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>

My custom ModelViewerGLSurfaceView (derived from GLSurfaceView) is needed for OpenGL rendering and works just fine.

Now I want to add gesture recognition. In order to do that I overridden OnTouchEvent in my ModelViewerGLSurfaceView, but this function is never called, no matter what I do.

However when I override OnTouchEvent on parent Activity, it works.

Why OnTouchEvent is never called for my GLSurfaceView?

Did you by any chance forget to register the onTouchListener?

You need to call setOnTouchListener on your view to register the callback.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM