-3

Here is the code i have tried

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

but the resulting layout look like this videoview

how to make video to occupy full screen and closing imageview should display above video at top right position?

Mithun Kumar
  • 595
  • 1
  • 9
  • 18
  • What you used is fine. You can use relative layout along with frame layout to achieve same with layout_gravity="top|right" for close image view. – Geek Mar 15 '17 at 07:14
  • @tahsinRupam i tried your code , but it was not working. – Mithun Kumar Mar 15 '17 at 08:03

3 Answers3

2

here is the trick.

 <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> 
Junaid Hafeez
  • 1,618
  • 1
  • 16
  • 25
1
<?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>
Chirag Prajapati
  • 25
  • 1
  • 1
  • 7
0

Try this,

    <?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>
Komal12
  • 3,340
  • 4
  • 16
  • 25