Use the layout file:
<?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/myvideo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"/>
</RelativeLayout>
Please note: you did not ask for this, but your code is from an example that can be seen elsewhere, where the infamous black flash will be displayed before and after the video. You need to add vidHolder.setZOrderOnTop(true);to avoid this (after #setVideoUri).
source
share