Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fullscreen VideoView isn't Centered

Tags:

android

I use this XML layout to show a fullscreen VideoView on my activity. The Video is fullscreen but it isn't centered. In landscape mode, it stays on the left side of the screen and leaves some blank spaces on the right side of the screen.

How can I make my VideoView placed in the center of the screen?

<?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
           android:layout_width="fill_parent"
           android:layout_height="fill_parent" >
   <VideoView android:id="@+id/myvideoview"
             android:layout_width="fill_parent"
             android:layout_alignParentRight="true"
             android:layout_alignParentLeft="true"
             android:layout_alignParentTop="true"
             android:layout_alignParentBottom="true"
             android:layout_height="fill_parent">
    </VideoView>
 </RelativeLayout>
like image 269
hectichavana Avatar asked Dec 13 '22 02:12

hectichavana


2 Answers

Try this layout,

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



         <VideoView android:id="@+id/videoview"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_centerInParent="true"/>

</RelativeLayout>
like image 198
Andro Selva Avatar answered Jan 02 '23 13:01

Andro Selva


Try this:

<?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
           android:layout_width="fill_parent"
           android:layout_height="fill_parent" >
   <VideoView android:id="@+id/myvideoview"
             android:layout_width="fill_parent"
             android:layout_height="fill_parent"
             android:layout_centerInParent="true">
    </VideoView>
 </RelativeLayout>

Hope this helps.

like image 40
Chronos Avatar answered Jan 02 '23 13:01

Chronos