视频设置为背景,但在顶部



我正在尝试将背景视频添加到我的应用程序的菜单中。但是顶部有一些空间。不知道为什么是。

<VideoView
    android:id="@+id/bgVideoView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:alpha="0"
    android:soundEffectsEnabled="false"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

有人可以告诉我我要在哪里出错吗?另外,有什么方法可以使视频变得黑暗。我尝试更改APLHA,但这似乎不起作用?

在您的Java文件中。动态分配指标。

videoview= (VideoView)permit.findViewById(R.id.videoview);
videoview.setVideoURI(vidUri);
DisplayMetrics metrics = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
vid_permit.setLayoutParams(new RelativeLayout.LayoutParams(metrics.widthPixels, metrics.heightPixels));
videoview.start();

感谢您的答案。但是,这解决了问题,不确定为什么..

 <ImageView
    android:id="@+id/imageView2"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:contentDescription="@image"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

最新更新