Reputation: 1446
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>
Upvotes: 4
Views: 7958
Reputation: 6682
If your VideoView cannot center in RelativeLayout you can try to put it into a FrameLayout like this:
<FrameLayout
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_gravity="center">
</VideoView>
</FrameLayout>
And then put this into RelativeLayout.
Upvotes: -1
Reputation: 54322
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>
Upvotes: 11
Reputation: 1962
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.
Upvotes: 3