Log in or register to post comments

Displaying Android views on top of OpenGL ES display layer

December 5, 2012 - 6:51pm #1

Hello, 

I've successfully modified the "ImageTargets" application and am able to render objects using OpenGL (pretty much modified the teapot rendering code). However, I am trying to also display a View type object (FrameLayout on top of a RelativeLayout). The code displays the Views fine on an independent app but when running on the app where OpenGL renders its objects, I cannot see any View objects. 

I'm not sure if Views can be viewd on top of OpenGL layer. So the question is, can you use Android views on top of OpenGL layer? If so, are there any concerns? Any hint would be helpful.

 

Thank you.

 

Displaying Android views on top of OpenGL ES display layer

December 8, 2012 - 1:07am #4

You're welcome.

 

About controlling of Z-order, this is typically based on the order you add views in your view tree (for instance, children typically sit on top of parent views, and within a set of siblings, last sibling sits on top);

however for advanced controlling of Z-order you might want to check the details in the Android website (Developer guide / API reference);

for instance there exist methods like View.bringToFront() to enforce a view to be shown on top, and other similar methods;

note however that when dealing with SurfaceViews (for example GLSurfaceView for OpenGL), Z-ordering is handled differently and can sometime be a bit tricky to get the desired ordering when mixing the surface view with "standard" views;

I would suggest  to also check the documentation about SurfaceView in the Android developer site; there might be interesting things you may want to learn there.

 

 

Displaying Android views on top of OpenGL ES display layer

December 7, 2012 - 4:25pm #3

Thank you it worked.

Too bad you cannot set a particular Z-order of layers (unless I'm missing something)

Displaying Android views on top of OpenGL ES display layer

December 6, 2012 - 7:14am #2

Hi, 

have a look at the "Dominoes" sample of the Vuforia sample distribution.

If you open Dominoes.java, you'll see some code like this:

addContentView(mGlView, new LayoutParams(

                                            LayoutParams.FILL_PARENT,

                                            LayoutParams.FILL_PARENT));

                            

                            addContentView(mGUIManager.getOverlayView(), new LayoutParams(

                                            LayoutParams.FILL_PARENT,

                                            LayoutParams.FILL_PARENT));

 

In the sample a RelativeLayout with some buttons is shown on top of everything else.

Both the OpenGL view and the RelativeLayout (as you can see from the code) are added on top of the root view (which is a FrameLayout), one after the other (first the OpenGL view is added and then the overlay view is added).

If you follow the same design scheme, you should be able to achieve the same result.

 

Log in or register to post comments