6

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>
Sharath
  • 691
  • 8
  • 23
prot0n
  • 193
  • 9
  • I didn't get what exactly you want from us? Do you want help in writing the XML layout? – Leonel Machava Aug 24 '12 at 10:14
  • 2
    I think the problem is not in the layout but in GLSurfaceView settup. By default it doesn't show transparent area no matter what I do, until I'm not setZOrderOnTop(true);, but this setting put surface all the way top... so how to have same layout composition and have transparent area in Glsurfaceview ? – prot0n Aug 24 '12 at 10:23

1 Answers1

3

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.

fadden
  • 51,356
  • 5
  • 116
  • 166