Android switch VideoView orientation from Portrait to Landscape without stretching the video horizontally -


I have an application that plays video from external storage. Videos look good in picture mode, but they are spread in landscape mode. Is there any easy way to set video playback width to landscape mode to fit video?

This is the activity of my video game:

  Expiration Listener on the implementation of the public class PlayVideoActivity Activity {see video private video; Private media controller controller; @ Override Protected Zero (Bundle Saved Instantstate) {Super. NET (Saved Instantstate); . GetWindow () requestFeature (Window.FEATURE_NO_TITLE); SetContentView (R.layout.activity_play_video); Video = (Watch Video) VVBIID (R.Did.Wel Video); Controller = new media controller (this); Video.setOnCompletionListener (this); Bundle Extras = Milentant (). GetExtras (); If (extra! = Null) {string videopath = extras .getString ("VideoPath"); Video.setVideoPath (videoPath); Controller.setMediaPlayer (video); Video.setMediaController (Controller); Video.requestFocus (); Video.start (); If (Saved InstanceState! = Null) {video.seekTo (Saved InstantState.Jet ("Current POS")); }}} @ Override Public Nil Termination (Media Player MP) {Finnish (); } @ Override protected savings to zero Instensstet (bundled Autstet) {if (Veediokispleing ()) {OutStatekputInt ( "current page", Veedioktredrantposhn ()); } Super.onSaveInstanceState (outState); }}  

Edit: activity_play_video.xml:

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android" Android: layout_width = "match_parent" Android: layout_height = "match_parent" Android: orientation = "vertical" & gt; & Lt; VideoView android: id = "@ + id / vwPlayVideo" Android: layout_width = "match_parent" Android: layout_height = "wrap_content" / & gt; & Lt; / LinearLayout & gt;  

Try the following in your .xml:

  & Lt; LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android" Android: Layout_width = "Match_parent" Android: Layout_height = "Match_parent" android: orientation = "vertical" android: gravity = "center" & Gt; & Lt; Videos android: id = "@ + id / vwPlayVideo" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" android: gravity = "center" / & gt; & Lt; / LinearLayout & gt;  

For the filling will not change full screen it Veedioretio to fill VideoView, try the following:

  Android: relative_layout Android: layout_width = "Fill_parent" Android: layout_height = "fill_parent" & gt; & Lt; VideoView Android: Leaut_vind = "Fel_perent" Android: Leaut_heit = "Fel_perent" Android: alignParentTop = "true" Android: alignParentLeft = "true" Android: alignParentRight = "true" Android: alignParentBottom = "true" / & gt; & Lt; / RelativeLayout & gt;  

Comments