1

I have an activity contains a NavigationDrawer and SmartGLView.

SmartGLView is inside DrawerLayout.

When NavigationDrawer show up, some part of it was covered by SmartGLView. How can I make NavigationDrawer on top of SmartGLView?

layout.xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/pl_drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<android.support.design.widget.NavigationView
    android:id="@+id/pl_nav_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:fitsSystemWindows="true"
    app:headerLayout="@layout/nav_header"
    app:menu="@menu/drawer_view">

</android.support.design.widget.NavigationView>

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/pl_tv_name"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="line1"
                android:textAlignment="center" />

            <TextView
                android:id="@+id/pl_tv_status"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="@string/normal"
                android:textAlignment="center" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/pl_tv_time"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="@string/defaultTime"
                android:textAlignment="center" />

            <TextView
                android:id="@+id/pl_tv_speed"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="@string/defaultSpeed"
                android:textAlignment="center" />
        </LinearLayout>


        <FrameLayout
            android:id="@+id/pl_frame_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <fr.arnaudguyon.smartgl.opengl.SmartGLView
                android:id="@+id/smartGLView"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />
        </FrameLayout>
    </LinearLayout>
</FrameLayout>

genpfault
  • 51,148
  • 11
  • 85
  • 139
hzyu
  • 72
  • 8
  • Try to move NavigationView to the bottom. – artem_p May 12 '18 at 04:44
  • After move NavigationView to the bottom, it works correctly in the emulator, but not in my phone. In my phone, I still can't see the part cover by SmartGLView, but I can click items in the menu. – hzyu May 12 '18 at 04:55
  • I have try different emulators, Pixel API 27 and API 22 works, Nexus S API 22 not works. – hzyu May 12 '18 at 05:19

1 Answers1

0

Move navigation view to the bottom.

The main content view (the first FrameLayout above) must be the first child in the DrawerLayout because the XML order implies z-ordering and the drawer must be on top of the content.

artem_p
  • 306
  • 2
  • 5
  • After move NavigationView to the bottom, it works correctly in the emulator, but not in my phone. In my phone, I still can't see the part cover by SmartGLView, but I can click items in the menu. – hzyu May 12 '18 at 05:03
  • What version of the Android is on your phone? – artem_p May 12 '18 at 05:05
  • Version of Android on my phone is Android 7.0 – hzyu May 12 '18 at 05:16
  • Try to call bringToFront() on the navigation view. Or ViewCompat.setTranslationZ. https://stackoverflow.com/questions/6759279/how-to-bring-view-on-front-of-everything – artem_p May 12 '18 at 05:36