My Android app is a fullscreen OpenGL ES 2.0 app, so the main content is a custom extension of GLSurfaceView. The activity layout looks like this:
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/drawer_layout">
<FrameLayout android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ListView android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:background="#111" />
</android.support.v4.widget.DrawerLayout>
I then add my GLSurfaceView using the addView method of the FrameLayout. If i don't do this, the Drawer works as expected.
The ListView seems to be pulled out correctly when i swipe it in, as i can't interact with the GLSurfaceView anymore until i swipe it back to the left. But it's not displayed at all, like the GLSurfaceView is allways rendered ontop of it.
How do i get a DrawerLayout working with a GLSurfaceView as its content?
I've just faced the same problem, and I've found quite a silly workaround for it. This issue seems to only affect DrawerLayouts, and not regular Views. So simply place an empty View over your GLSurfaceView, to mask it away from the Drawer.
Here's my stripped down layout file as a sample for you:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<GLSurfaceView
android:id="@+id/glSurfaceView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<View
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
<FrameLayout
android:id="@+id/frameLayoutDrawer"
android:layout_width="@dimen/navigation_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="end"
android:background="@android:color/white" />
</android.support.v4.widget.DrawerLayout>
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