视频视图中的Android全宽

M U*_*ama 0 android android-layout android-activity android-videoview

我试图将线性布局或相对布局内的视频视图拉伸到全屏,但应用程序不会将视频视图的宽度拉伸到Android屏幕.左右各有10到15 dp的空间.线性布局以及相对布局也不会拉伸到全屏.我希望它在width.i中填充屏幕也试过"match_parent"代替"fill_parent",但结果是一样的.这是我的代码

 <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" />
Run Code Online (Sandbox Code Playgroud)

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();
Run Code Online (Sandbox Code Playgroud)

Dav*_*vid 8

<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>
Run Code Online (Sandbox Code Playgroud)