Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Video View size changed automatically depending upon video size?

Hi I have created video view application its working fine. but my video view size changed automatically depending upon the video height and width but i wish to play video in video view size how to resolve 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 define value for videoview height and width manually, if i play video in this height and width automatically change this height and width on video height and width i no need to change video view size, I need to change video size depanding upon then video view height and width screen size that's all....

like image 613
user2025358 Avatar asked Jan 30 '13 12:01

user2025358


1 Answers

Yes its weird, i face the same situation ,actually i wanted video to be in fullscreen mode,i tried it keeping main layout as relative and all alignment of VideoView to 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>
like image 86
user939997 Avatar answered Nov 04 '22 07:11

user939997