How to add GLSurfaceView between Android views?

I am working on a special interface in Android-Sandwich, a small GalleryView on GLSurfaceView (with transparent areas) on top of the background view (LinearLayout + some widgets). This is how I am going to configure it:

<User> 

TOP View
--- GalleryView
|
--- GLSurfaceView (with transparent areas)
|
--- LinearLayout (with widgets)
BOTTOM View

In normal mode, GLSurfaceView has a black background on transparent areas, so I don’t see the bottom layer, but when I use setZOrderOnTop (true); I see the bottom layer, but the top layer (gallery) also follows the Glsurface view. How can I fulfill the required representation, as in the diagram?

XML Mannequin Example (using AnalogClock instead of GalleryView):

 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/RelativeLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#920000" android:orientation="vertical" > <LinearLayout android:id="@+id/LinearLayout1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|right" > <AnalogClock android:id="@+id/analogClock2" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> <com.test.CustomGlView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/gl_view" android:layout_width="fill_parent" android:layout_height="fill_parent" /> <AnalogClock android:id="@+id/Gallery_dummyview" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </RelativeLayout> 
+6
source share
1 answer

You cannot do this.

The GLSurfaceView surface is on a separate composition layer from the View-based user interface. It may be above or below Views, but it cannot seem to be sandwiched between View elements.

Instead, you can use TextureView (API 14+). It has a surface for rendering, but is attached to the View layer by the application, so the layout works just like any other view. You will need to provide your own EGL setup and flow control for GLES instead of relying on what is in GLSurfaceView, but you can find examples in Grafika .

+2
source

Source: https://habr.com/ru/post/923651/


All Articles