2011-11-22 68 views
4

是否可以在GLSurfaceView上添加LinearLayout? 如何通過GLSurfaceView疊加LinearLayout? 也許GLSurfaceView是Game playground,而LinearLayout是菜單式的〜Android GLSurfaceView

回答

12

使用一個FrameLayout。將GLSurfaceView作爲FrameLayout中的第一個視圖,然後再添加LinearLayout。這將使的LinearLayout和任何在它在GLSurfaceView的頂部:

<FrameLayout 
    android:id="@+id/graphics_frameLayout1" 
    android:layout_width="fill_parent" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_height="fill_parent"> 
    <android.opengl.GLSurfaceView 
     android:id="@+id/graphics_glsurfaceview1" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 
    </android.opengl.GLSurfaceView> 
    <LinearLayout 
     android:layout_height="fill_parent" 
     android:id="@+id/linearLayout1" 
     android:gravity="center" 
     android:layout_width="fill_parent" 
     android:orientation="vertical"> 
    </LinearLayout> 
</FrameLayout> 

編輯:現在用圖片:

Android Framelayout for games. Check out ma ms paint skillz

+0

我已經基本上做到了這一點與JAVA而不是XML,但glSurfaceView有一個固有的onDraw方法,看來這個方法總是把glSurface帶回頂部.. – erik

+0

你怎麼使用glSurfaceView?你在擴展它還是附加一個渲染器? –

+0

擴展它並做relview.addview(glView); – erik