Android 在导航抽屉下方的片段上播放视频

Android 在导航抽屉下方的片段上播放视频,android,navigation-drawer,Android,Navigation Drawer,我正在尝试编写一个简单的代码来播放原始文件夹中的视频,我必须在片段上播放视频,但我的活动有一个导航抽屉,所以当我第一次尝试播放此视频时,只有语音,没有视频,所以我搜索此问题,然后我得到了一个解决方案videoView.setZOrderOnTop(true)但现在我面临的另一个问题是导航抽屉上出现了视频窗口。这是屏幕截图 这是我的xml布局 这是活动用的 <?xml version="1.0" encoding="utf-8"?> <android.support.v4.wi

我正在尝试编写一个简单的代码来播放原始文件夹中的视频,我必须在片段上播放视频,但我的活动有一个导航抽屉,所以当我第一次尝试播放此视频时,只有语音,没有视频,所以我搜索此问题,然后我得到了一个解决方案
videoView.setZOrderOnTop(true)
但现在我面临的另一个问题是导航抽屉上出现了视频窗口。这是屏幕截图

这是我的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"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true" tools:openDrawer="start">

<include layout="@layout/app_bar_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:fitsSystemWindows="true"
    app:headerLayout="@layout/nav_header_main"
    app:menu="@menu/activity_main_drawer"
    style="@style/textDisply2.title"
    >

    <TextView
        android:id="@+id/nav_call_sleep_care"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_gravity="bottom"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:background="@color/buttonColor"
        android:gravity="center"
        android:drawablePadding="@dimen/column_padding"
        android:drawableLeft="@mipmap/call_care_small"
        android:textColor="@android:color/black"
        android:textSize="@dimen/home_wh_btn_txt"
        android:text="@string/call_sleep_care" />

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

</android.support.v4.widget.DrawerLayout>

这是我的片段布局

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/transparent"
    >
    <TextView
        android:id="@+id/screen_name"
        android:text="@string/video"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="@style/TextAppearance.AppCompat.Title"
        />

    <LinearLayout
        android:layout_below="@+id/screen_name"
        android:id="@+id/video_dis_box"
        android:layout_marginTop="50dp"
        android:gravity="center_vertical"
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

        <ImageView
            android:id="@+id/play_video_btn"
            android:layout_width="@dimen/img_btn_height_play"
            android:layout_height="@dimen/img_btn_width_play"
            android:src="@mipmap/music"
            />

        <LinearLayout
            android:padding="@dimen/column_padding"
            android:orientation="vertical"
            android:layout_weight="1"
            android:layout_marginLeft="@dimen/activity_horizontal_margin"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">

            <TextView
                android:id="@+id/video_title"
                android:text="@string/video_title"
                style="@style/textDisply2.subHead"
                />

            <TextView
                android:id="@+id/dr_surendra"
                android:text="@string/dr_surendra"
                style="@style/textDisply2.subHead"
                android:textSize="@dimen/home_color_btn_txt"

                />

        </LinearLayout>


        <ImageView
            android:id="@+id/lock"
            android:layout_width="@dimen/img_btn_height_lock"
            android:layout_height="@dimen/img_btn_width_lock"
            android:src="@mipmap/lock"
            />

    </LinearLayout>

        <VideoView
            android:layout_below="@+id/video_dis_box"
            android:id="@+id/play_video"
            android:layout_centerInParent="true"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            />

</RelativeLayout>


请给我建议解决方案。

我认为调用
videoView.setZOrderOnTop(true)
是没有意义的

我认为你最好关闭导航抽屉

因此,在您的代码中,例如:

DrawerLayout drawerLayout = (DrawerLayout) findViewById(drawer_layout);
NavigationView navigationView = (NavagationView) findViewById(nav_view);
drawerLayout.closeDrawer(navigationView);
将关闭抽屉,视频视图将不会隐藏


注意:关闭抽屉的代码可能因您的情况而异。

请发布您的xml布局。感谢您的回复hata我添加了xml请检查谢谢您的建议hata但无效我发现我的错误我在删除此和videoView时在应用程序样式中设置了背景色。setZOrderOnTop(true)视频工作的罚款碎片和下面显示导航抽屉感谢帮助哈塔。