DrawerLayout ListView not displaying with GLSurfaceView as content

My Android application is a full-screen OpenGL ES 2.0 application, so the main content is the user extension GLSurfaceView. The action layout is as follows:

<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> 

Then I add my GLSurfaceView using the addView method for FrameLayout. If I do not, the box works as expected.

The ListView seems to have pulled correctly when I held it, since I can no longer interact with GLSurfaceView until I hold it to the left. But it does not display at all, as GLSurfaceView is always displayed on it.

How to get DrawerLayout working with GLSurfaceView as its contents?

+7
java android listview opengl-es
source share
1 answer

I ran into the same problem and I found a pretty stupid workaround for her. This issue seems to affect only DrawerLayouts and not regular views. So just put an empty view above your GLSurfaceView to hide it from the drawer.

Here is my cleaned 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> 
+16
source share

All Articles