【问题标题】:Android GLSurfaceViewAndroid GLSurfaceView
【发布时间】:2011-11-22 14:50:15
【问题描述】:

是否可以在 GLSurfaceView 上添加 LinearLayout? 如何在 GLSurfaceView 上覆盖 LinearLayout? 或许 GLSurfaceView 是 Game playground 而 LinearLayout 是 menubar~

【问题讨论】:

    标签: android opengl-es glsurfaceview


    【解决方案1】:

    使用框架布局。将 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>
    

    编辑:现在有图片:

    【讨论】:

    • 我基本上是用 JAVA 而不是 xml 完成的,但是 glSurfaceView 有一个固有的 onDraw 方法,而且看起来这个方法总是把 glSurface 带回顶部..
    • 您如何使用 glSurfaceView?你是扩展它还是附加一个渲染器?
    • 扩展它并做 relview.addview(glView);
    • 我使用 GLSurfaceView.Renderer。我忘记了如何通过扩展 GLSurfaceView 来做到这一点:P。如果您还没有附上代码,也许可以作为一个单独的问题发布?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-04
    • 1970-01-01
    • 1970-01-01
    • 2014-04-22
    相关资源
    最近更新 更多