Recently I was playing with VideoView of Android SDK and my video was not displaying on the complete screen. It was varying device to device leaving some blank screen around depending upon the screen resolution of those devices. By default, Android will scale the video to fit the VideoView but keep the video aspect ratio. That means that depending on the device’s screen size there might be some black spaces left around the video as it’s not filling the screen.



You may want to display video in parent container area in full width and height but VideoView doesn’t provide an explicit way to specify the filling mode, you can achieve the same result by wrapping the video view in a RelativeLayout and setting the VideoView alignments to match the parent’s boundaries:

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

    

Here is the output of above code with RelativeLayout as well as with LinearLayout.

video_streching

 

This article has 3 comments

  1. Michael Scheucher Reply

    In my case it is not working… If I do it that way it is stretched to the width/height of the parent container but the ratio is not kept… So the result is awful… Do you have any ideas what I am doing wrong?!

    Thanks in advance!

  2. Warbington55757 Reply

    You are my inhalation, I have few blogs and sometimes run out from to post : (.

Leave a Reply to Warbington55757 Cancel reply

Your email address will not be published. Required fields are marked *