Navigation Drawer and VideoView in android
<p>I am using a navigation drawer plus a tablayout. I have a video in my tab which was not visible at first, but I can hear the sound. Once I set</p>

<pre><code>video_view.setZOrderOnTop(true);
</code></pre>

<p>and I can also see the video, but this causes an <strong>issue</strong> with navigation drawer. </p>

<p>When I slide it, the video doesn't hide behind the navigation drawer as do all other elements. </p>

<p><a href="https://i.stack.imgur.com/NqGKV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/NqGKV.png" alt="enter image description here"></a></p>

<p>If I don't use</p>

<pre><code>video_view.setZOrderOnTop(true);
</code></pre>

<p>then my drawer is works fine. </p>

<p>main_activity.xml</p>

<pre><code>&lt;android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"&gt;

&lt;!-- Framelayout to display Fragments --&gt;
&lt;android.support.design.widget.CoordinatorLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"&gt;

    &lt;android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"&gt;

        &lt;android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"&gt;

                &lt;ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/menuwhite2"
                    android:id="@+id/custom_home"
                    android:gravity="center"
                    android:layout_gravity="right"
                    android:layout_marginRight="10dp"/&gt;

                &lt;android.support.design.widget.TabLayout
                    android:id="@+id/tabs"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    app:tabMode="fixed"
                    app:tabGravity="fill"
                    /&gt;

        &lt;/android.support.v7.widget.Toolbar&gt;
    &lt;/android.support.design.widget.AppBarLayout&gt;

    &lt;android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"  /&gt;
&lt;/android.support.design.widget.CoordinatorLayout&gt;


&lt;!-- Listview to display slider menu --&gt;
&lt;ListView
    android:id="@+id/list_slidermenu"
    android:layout_width="240dp"
    android:layout_height="match_parent"
    android:layout_gravity="end"
    android:choiceMode="singleChoice"
    android:divider="@color/list_divider"
    android:dividerHeight="1dp"
    android:listSelector="@drawable/list_selector"
    android:background="@color/list_background"/&gt;
</code></pre>

<p></p>

<p>tab_fragment.xml</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    &gt;

    &lt;android.support.v7.widget.CardView
        android:id="@+id/cardview"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"&gt;

        &lt;TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="hello"/&gt;
    &lt;/android.support.v7.widget.CardView&gt;

    &lt;RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" &gt;

        &lt;RelativeLayout
            android:id="@+id/layoutTop"
            android:layout_width="match_parent"
            android:layout_height="match_parent"&gt;

            &lt;VideoView
                xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/video_player_view"
                android:layout_height="200dp"
                android:layout_width="fill_parent"/&gt;

        &lt;/RelativeLayout&gt;

        &lt;RelativeLayout
            android:id="@+id/layoutBottom"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/layoutTop"&gt;

            &lt;TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="hello"/&gt;

        &lt;/RelativeLayout&gt;
        &lt;ImageView
            android:id="@+id/overlapImage"
            android:layout_width="wrap_content"
            android:layout_height="40dp"
            android:layout_above="@id/layoutBottom"
            android:adjustViewBounds="true"
            android:src="@mipmap/ic_launcher" /&gt;

    &lt;/RelativeLayout&gt;
&lt;/LinearLayout&gt;
</code></pre>

<p>TabFragment.java</p>

<pre><code>@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    final View view = inflater.inflate(R.layout.tab_fragment, container, false);
    VideoView video_player_view = (VideoView) view.findViewById(R.id.video_player_view);
    video_player_view.setVideoURI("videourl");
    video_player_view.setZOrderOnTop(true);
    video_player_view.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
             @Override
             public void onPrepared(MediaPlayer mp) {
                 video_player_view.start();
             }
         });        
    return  view;
}
</code></pre>

<p>So can Anyone guide me with an alternative for that.</p>