Reputation: 986
I have a VideoView, which is rotated 90 degrees. This results in an ugly black bar on the side. Which would normally be under the MediaController (I think). I can't find an XML attribute to kill it and haven't found anything in VideoView documentation. I'm not having any luck with Google either because I'm probably not using good search terms, as I don't know what it is. Anyone know how to get rid of this??
My code is simple. I have a parent layout with a VideoView in XML, both set to match parent. Java:
this.viewer = (VideoView) findViewById(R.id.vid_view);
this.viewer.setVideoPath(Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES) + "/Folder/" + video);
this.mc = new MediaController(this);
this.mc.setMediaPlayer(this.viewer);
this.viewer.setMediaController(this.mc);
this.viewer.requestFocus();
this.viewer.start();
Upvotes: 1
Views: 2844
Reputation: 1006614
The aspect ratio of a video may not match the aspect ratio of the screen, or the portion of the screen taken up by the VideoView
.
Your choices are:
Use android:gravity
to position the black bar, such as centering it for a "letterbox" effect, or
Try using negative margins, so portions of the too-long dimension lie outside the screen, though this will chop off those portions of the video
The latter technique works for camera previews; I have not tried it with videos and VideoView
. It would also require some runtime calculations, unless you happen to know the aspect ratio of your videos in advance.
Upvotes: 2