Does Android support scaling Video?

haseman picture haseman · Jan 15, 2010 · Viewed 32.1k times · Source

Using a VideoView is it possible to set a scale factor for Android? By Default the video view resizes itself to fit the encoded resolution of the Video. Can I force Android to render a video into a smaller or larger rect?

Answer

Michał Kowalczuk picture Michał Kowalczuk · Jan 7, 2011

(I know it's very old question, but there is another way to control dimensions, which isn't described here, maybe someone will find it helpful.)

Declare your own MyVideoView class in your layout and write your own onMeasure() method. Here is how to run video stretched to original View's dimensions:


public class MyVideoView extends VideoView {
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
  int width = getDefaultSize(0, widthMeasureSpec);
  int height = getDefaultSize(0, heightMeasureSpec);

  setMeasuredDimension(width, height);
 }
}