title: Resize VideoView
body: <p>I am attempting to dynamically set the size of an Android VideoView. I have looked on StackOverflow as well as the internet; and the best solution I found was from <a href="http://clseto.mysinablog.com/index.php?op=ViewArticle&amp;articleId=2992625" rel="noreferrer">here</a>. I have put my implementation below:</p>
  <pre><code>public class ResizableVideoView extends VideoView {
  
      public ResizableVideoView(Context c) {
          super(c);
      }
  
      private int mVideoWidth = 100;
      private int mVideoHeight = 100;
  
      public void changeVideoSize(int width, int height) {
          mVideoWidth = width;      
          mVideoHeight = height;
  
          // not sure whether it is useful or not but safe to do so
          getHolder().setFixedSize(width, height); 
          
          forceLayout();
          invalidate(); // very important, so that onMeasure will be triggered
      } 
  
      public void onMeasure(int specwidth, int specheight) {
          Log.i(&quot;onMeasure&quot;,&quot;On Measure has been called&quot;);
          setMeasuredDimension(mVideoWidth, mVideoHeight);
      }
  
      public void onDraw(Canvas c) {
          super.onDraw(c);
          Log.i(&quot;onDraw&quot;,&quot;Drawing...&quot;);
      }
  }
  </code></pre>
  <p>The video resizes correctly on the Android emulator as well as on a Motorola Droid X; but on a Motorola Droid, the VideoView resizes but the video playing in the VideoView does not resize. On the Motorola Droid, if the VideoView is set to a larger dimension than the video playing, a black background appears in the VideoView with the video playing in the top left corner of the VideoView on top of the black background.</p>
  <p>How does one resize a VideoView properly in Android?</p>
  <p>Thanks,
  Vance</p>