Android VideoView in full screen maintains aspect ratio
I am working with a splash screen in my application. I would like to have a background video in it. My video is 1280x720 and it should be in full screen portrait mode.
My code works, but then it stretches the height of the video.
What I want is to get it centered while the height is 100% on screen.
VideoView videoview = (VideoView) findViewById(videoView);
Uri uri = Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.splash);
videoview.setVideoURI(uri);
videoview.start();
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical|center_horizontal"
tools:context="cn.nekocode.camerafilter.splash">
<VideoView
android:id="@+id/videoView"
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"/>
</RelativeLayout>
+3
source to share
No one has answered this question yet
Check out similar questions: