Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make video full screen and keep aspect ratio?

I have a video in one size and would like from it to display full size all the time no matter the size of the screen. At the same time I would like to keep aspect ratio of that video so it doesn't stretch i create a bad look.

I can accomplish that stretch effect like this but the video looks bad then:

<?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/videoViewRelative"
         android:layout_alignParentTop="true"
         android:layout_alignParentBottom="true"
         android:layout_alignParentLeft="true"
         android:layout_alignParentRight="true"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent">
    </VideoView>

</RelativeLayout>

In my this case it is not important to show whole video to user so I need something like how it's done for ImageView:

android:scaleType="centerCrop"

Is there any crop alternative for VideoView? Thank you :)

like image 571
user4386126 Avatar asked May 18 '15 20:05

user4386126


1 Answers

You can try to use this library

https://github.com/dmytrodanylyk/video-crop

like image 125
JoaoBiriba Avatar answered Sep 21 '22 11:09

JoaoBiriba