如何使 videoview 全屏并在其上方放置一个关闭图像视图?

how to make videoview full screen and place a closing imageview above it?

这是我试过的代码

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_video_player"
android:layout_width="match_parent"
android:layout_height="match_parent">
<VideoView
    android:id="@+id/videoView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    />
<ImageView
    android:layout_gravity="top|right"
    android:src="@android:drawable/ic_menu_close_clear_cancel"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

</FrameLayout>

但最终的布局看起来像这样

如何让视频占满屏幕并且关闭imageview应该显示在视频上方右上角?

试试这个,

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <RelativeLayout
            android:id="@+id/relativeLayout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="20dp">

            <VideoView
                android:id="@+id/videoView"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fitsSystemWindows="true" />
        </RelativeLayout>

        <ImageView
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:layout_alignParentEnd="true"
            android:layout_alignParentTop="true"
            android:layout_margin="10dp"
            android:src="@drawable/placeholder" />

    </RelativeLayout>

这是诀窍。

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

    <VideoView
        android:id="@+id/videoView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"
        android:layout_alignParentTop="true"
        android:fitsSystemWindows="true"
        />
    <ImageView
        android:layout_gravity="top|right"
        android:src="@android:drawable/ic_menu_close_clear_cancel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_alignParentRight="true" />
    </RelativeLayout> 
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <VideoView
        android:id="@+id/video_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true" />

    <ImageView
        android:id="@+id/close_logo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:scaleType="centerCrop"
        android:src="@drawable/button_close" />
</RelativeLayout>