Android Full Width in Video View

3k views Asked by At

I am trying to stretch my video view inside the linear layout or relative layout to full screen but the application does not stretches the width of the video view same to android screen. There is always 10 to 15 dp space on left and right each. Also the Linear layout and also relative layout is not stretching to full screen. I want it to fill the screen in width.i have also tried "match_parent" in place of "fill_parent" but the result is same. Here is my code

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res    /android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bgsong"
android:orientation="vertical"
 >

<VideoView
    android:id="@+id/video_view"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true" />

video_player_view = (VideoView) findViewById(R.id.video_view);
    dm = new DisplayMetrics();
    this.getWindowManager().getDefaultDisplay().getMetrics(dm);
    int height = dm.heightPixels;
    int width = dm.widthPixels;
    video_player_view.setMinimumWidth(width);
    video_player_view.setMinimumHeight(height);
    Uri uri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.video);
    video_player_view.setVideoURI(uri); 
    video_player_view.start();
2

There are 2 answers

0
David On BEST ANSWER
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent" >

<VideoView
    android:id="@+id/videoView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_centerInParent="true"
    android:layout_centerVertical="true" />

</RelativeLayout>
1
Sajidkhan On

Actually the video's aspect ratio does not match the screen's aspect ratio that's why you get such problem, if you want to continue with this and the UI you had made look pretty handsome, just set background color to LinearLayout. i.e android:background="#000000"