视频在任何布局中都不居中 [Android]

Maw*_*Boc 2 android android-videoview

我正在尝试将在全屏活动中播放的视频居中,但我在任何布局中放置的任何参数似乎都不起作用

这是我的清单:

<activity
    android:name=".VideoActivity"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
</activity>
Run Code Online (Sandbox Code Playgroud)

我的 video_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent">

  <VideoView 
    android:id="@+id/videoView" 
    android:gravity="center"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"/>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

以及您需要时的活动

public class VideoActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.video_layout);

    VideoView videoHolder = new VideoView(this);
    setContentView(videoHolder);
    Uri video = Uri.parse("android.resource://" + getPackageName() + "/"+ R.raw.video);
    videoHolder.setVideoURI(video);
    videoHolder.start();

    videoHolder.setOnCompletionListener(new OnCompletionListener() {
        public void onCompletion(MediaPlayer mp) {
            jump();
        }
    });
}   

private void jump() {
    if(isFinishing())
      return;
     finish();
     pd.dismiss();
    }
 }
Run Code Online (Sandbox Code Playgroud)

我尝试过 FrameLayou、RelativeLayout、LinearLayout

重心居中,layout_gravity 居中,纵向显示在窗口顶部,横向显示在左下角

我会放一张照片,但我缺乏声誉,提前致谢

Com*_*are 5

这对我有用:

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

    <VideoView
        android:id="@+id/video_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center">
    </VideoView>

</FrameLayout>
Run Code Online (Sandbox Code Playgroud)