title: Android: Mediaplayer: How to use SurfaceView or mediaplayer to play video in correct size
body: <p>I am playing local video file using MediaPlayer and SurfaceView. SurfaceView is the only control in activity, while my video files are QVGA or other. Problem is that video is getting stretched, How can i play video in its original size e.g. qvga with remaining area black.</p>
  
  <p>From iteration,</p>
  
  <p>When i am forcefully sets layout_height/width of Surfaceview in XML, video displayed fine.
  <code>surface_holder.setFixedSize(w,h)</code> has no effect, neither mp.setdisplay().</p>
  
  <p>Please guide in this.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>XML flie</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
              android:id="@+id/home_container"  
              android:layout_width="fill_parent" 
              android:layout_height="fill_parent"&gt;
  
  &lt;SurfaceView 
          android:id="@+id/surface" 
          android:layout_width="fill_parent" 
          android:layout_height="wrap_content" 
          android:paddingTop="10dip" /&gt;
  &lt;/framelayout&gt;
  </code></pre>
  
  <p>MediaPlayer usage is as per following link</p>
  
  <p><a href="http://davanum.wordpress.com/2007/12/29/android-videomusic-player-sample-from-local-disk-as-well-as-remote-urls/" rel="noreferrer">http://davanum.wordpress.com/2007/12/29/android-videomusic-player-sample-from-local-disk-as-well-as-remote-urls/</a></p>
  
  <p>Thanks in advance.</p>