Android: Adding extended GLSurfaceView to a Layout don't show 3d stuff

Posted by Santiago on Stack Overflow See other posts from Stack Overflow or by Santiago
Published on 2010-04-11T05:31:36Z Indexed on 2010/04/11 5:33 UTC
Read the original article Hit count: 1215

Filed under:
|
|
|

I make a game extending the class GLSurfaceView, if I apply SetContentView directly to that class, the 3d stuff and input works great.

Now I want to show some items over 3d stuff, so I create a XML with a layout and some objects, and I try to add my class manually to the layout. I'm not getting errors but the 3d stuff is not shown but I can view the objects from XML layout.

source:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); 
layout = (RelativeLayout) inflater.inflate(R.layout.testlayout, null); 

//Create an Instance with this Activity
    my3dstuff = new myGLSurfaceViewClass(this);
    layout.addView(my3dstuff,4);

    setContentView(R.layout.testlayout);
}

And testlayout have:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content" android:id="@+id/Pantalla">

<ImageView android:id="@+id/zoom_less" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/zoom_less"></ImageView>
<ImageView android:id="@+id/zoom_more" android:layout_width="wrap_content" android:src="@drawable/zoom_more" android:layout_height="wrap_content" android:layout_alignParentRight="true"></ImageView>
<ImageView android:id="@+id/zoom_normal" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/zoom_normal" android:layout_centerHorizontal="true"></ImageView>
<ImageView android:id="@+id/stop" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/stop" android:layout_centerInParent="true" android:layout_alignParentBottom="true"></ImageView>
</RelativeLayout>

I also tried to add my class to XML but the Activity hangs up.

<com.mygame.myGLSurfaceViewClass android:id="@+id/my3dstuff" android:layout_width="fill_parent" android:layout_height="fill_parent"></com.mygame.myGLSurfaceViewClass>

and this don't works:

<View class="com.mygame.myGLSurfaceViewClass" android:id="@+id/my3dstuff" android:layout_width="fill_parent" android:layout_height="fill_parent"></View>

Any Idea? Thanks

© Stack Overflow or respective owner

Related posts about android

Related posts about glsurfaceview