title: How can I preserve my Android VideoView's aspect ratio in proportion to its height only?
body: <p>I want to set a video that fills the screen and preserves its aspect ratio. However, I do not want the video to match the aspect ratio of the phone.</p>
  
  <p>If my screen's aspect ratio is 18.9:9 and the video's aspect ratio is 16:9, then the video appears stretched when I put it in a VideoView that inherits fill_parent. If I don't set fill_parent then the video preserves its aspect ratio but only occupies less than a 1/3 of the screen because the aspect ratio is determined by its width, not its height. This is not desirable.</p>
  
  <p>I want to fill the screen vertically with the video, regardless if part of the width is clipped off.</p>
  
  <p>Current Code:</p>
  
  <pre><code>window.setFormat(PixelFormat.TRANSLUCENT)
  val videoView = findViewById &lt; VideoView &gt; (videoView)
  val video = Uri.parse("android.resource://" + packageName + "/" +
      R.raw.bgvideo)
  videoView.setVideoURI(video)
  videoView.setOnPreparedListener {
      mp: MediaPlayer - &gt;
          mp.setVideoScalingMode(MediaPlayer.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING)
      mp.isLooping = true
      mp.setScreenOnWhilePlaying(false)
  }
  videoView.start()
  </code></pre>
  
  <p>XML:</p>
  
  <p>
  </p>
  
  <pre><code>&lt;VideoView
      android:id="@+id/videoView"
      android:layout_width="2000dp"
      android:layout_height="match_parent" /&gt;
  
  &lt;!--- Sample Foreground Content !---&gt;
  &lt;ImageView
      android:layout_width="wrap_content"
      android:layout_height="250dp"
      android:layout_gravity="center_horizontal"
      android:layout_marginBottom="24dp"
      android:contentDescription="@string/logo"
      android:src="@drawable/logo" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>Current Result:</p>
  
  <p><a href="https://i.stack.imgur.com/FFh2m.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FFh2m.png" alt="enter image description here"></a></p>
  
  <p>Desired Outcome:
  <a href="https://i.stack.imgur.com/owyk5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/owyk5.png" alt="enter image description here"></a></p>