0

By using android VideoView can't display the complete width of video at the screen. Right side of the screen displays the background image. That means 75% of screen width (left side) displays the video and other 25% of the screen (right side) displays the background image.

Below is my code.

MainActivity.java

final VideoView videoView  =(VideoView)child.findViewById(R.id.video_player);

                MediaController mediaController= new MediaController(this);
                mediaController.setAnchorView(videoView);
                Uri uri=Uri.parse("http://www.androidbegin.com/tutorial/AndroidCommercial.3gp");
                videoView.setMediaController(mediaController);
                videoView.setVideoURI(uri);
                videoView.requestFocus();


                videoView.start();

activity_main.xml

<LinearLayout
        android:layout_height="200dp"
        android:orientation="vertical"
        android:layout_width="match_parent">

        <VideoView
            android:id="@+id/video_player"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    </LinearLayout>

How to display the full width of video in android-video view ?

Johny
  • 625
  • 2
  • 6
  • 26
Nuwan Withanage
  • 393
  • 7
  • 19
  • Have a look into [This discussion](https://stackoverflow.com/questions/13603553/videoview-to-match-parent-height-and-keep-aspect-ratio). – ADM Jan 12 '18 at 10:35

1 Answers1

0

Use Relative Layout and put VideoView inside that :

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent" android:layout_height="match_parent">

    <VideoView
        android:id="@+id/VideoView"
        android:layout_alignParentTop="false"
        android:layout_alignParentBottom="false"
        android:layout_alignParentLeft="false"
        android:layout_alignParentRight="false"
        android:layout_width="match_parent"
        android:keepScreenOn="true"
        android:layout_height="match_parent"
        android:layout_centerHorizontal="true" />

</RelativeLayout>
Johny
  • 625
  • 2
  • 6
  • 26
Rahul
  • 76
  • 7