簡體   English   中英

GLSurfaceView OnTouchEvent從未調用

[英]GLSurfaceView OnTouchEvent never called

在我的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?

您是否偶然忘記注冊onTouchListener?

您需要在視圖上調用setOnTouchListener來注冊回調。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM