Why did the video image size change automatically depending on the size of the video?

Hi, I created an application to watch a video in its working condition. but the size of my video image changed automatically depending on the height and width of the video, but I want to play the video as a video viewer, how to solve this problem.

This is my code:

public class MainActivity extends Activity { String SrcPath = "/sdcard/maatraan.3gp"; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); VideoView myVideoView = (VideoView)findViewById(R.id.myvideoview); myVideoView.setVideoURI(Uri.parse(SrcPath)); myVideoView.setMediaController(new MediaController(this)); myVideoView.requestFocus(); myVideoView.start(); } } 

xml code:

 <VideoView android:id="@+id/myvideoview" android:layout_width="400dp" android:layout_height="400dp" /> </LinearLayout> 

I determine the value for the height and width of the video image manually, if I play the video in this height and width, I automatically change this height and width to the height and width of the video. I do not need to change the size of the video image, I need to change the size of the video, then the size of the video image height and width of the screen, which is all ....

+4
source share
1 answer

Yes, this is strange, I am facing the same situation, in fact, I wanted the video to be in full screen mode, I tried to save the main layout as relative, and the entire alignment of VideoView was true, and it worked.

 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <VideoView android:id="@+id/videoView1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:keepScreenOn="true" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:layout_alignParentRight="true" android:layout_alignParentBottom="true" /> </RelativeLayout> 
+5
source

All Articles