0

I have a stranger problem using VideoView.

Using some .mp4 (coded using ffmpeg) video i have this problem:

Video is stretch

The video is stretch to cover all screen-width.

But using .mp4 video coded using a different software(i don't remember it) the result is:

Video is not stretch

The aspect ratio is preserved.

This is my layout XML:

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

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/allenamento_activity">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <VideoView
                android:id="@+id/videoView"
                android:layout_width="match_parent"
                android:layout_height="200dp"
                android:layout_marginTop="2dp"
                android:layout_gravity="center">
            </VideoView>

            <---- OTHER XML CODE ------>

        </LinearLayout>
    </ScrollView>
</RelativeLayout>

How can i prevent the stretching of the video?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
BertoGT
  • 23
  • 5

1 Answers1

-3

The scrollview and all children are all set to:

android:layout_width="match_parent"

which would entail all children will be the same width as the screen/primary layout.

You either need to calculate the needed height/width or wrap content on width and height.

The onMeasure method may be of use here?

Jcov
  • 2,122
  • 2
  • 21
  • 32
  • Searching on the web, i tried to use `Relative Layout` as VideoView's container and i tried to compute its widht necessary to preserve the aspect ratio but without results... – BertoGT Feb 15 '18 at 22:12