I'm working on a special UI in Android -Sandwich type, a small GalleryView on GLSurfaceView(with transparent areas) on top of background View (LinearLayout+some widgets). This is how I'm thinking of setting it up:
<User>
TOP View
---GalleryView
|
---GLSurfaceView(with transparent areas)
|
---LinearLayout(with widgets)
BOTTOM View
In regular mode GLSurfaceView have black background on transparent areas, so I cannot see the bottom layer,but when I use setZOrderOnTop(true); I can see bottom layer, but the top layer (gallery) also goes behind Glsurface view. How can I accomplish desired view like in schema?
XML code dummy Example(with 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>
You can't do this.
The GLSurfaceView's Surface is on a separate composition layer from the View-based UI. It can be above the Views or below them, but it can't appear sandwiched between View elements.
You can use a TextureView (API 14+) instead. It has a Surface to render to, but is composited onto the View layer by the app, so the layout works just like any other View. You'll need to provide your own EGL setup and thread management for GLES instead of relying on what's in GLSurfaceView, but you can find examples in Grafika.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With