整个屏幕上的视频背景

时间:2016-12-19 20:47:50

标签: android xml android-videoview

我希望在整个屏幕上都有视频背景。一切都在java中正常工作:它循环等问题可能在xml中。 目前我在屏幕顶部有视频,它看起来像这样:(视频完全适合边缘)enter image description here

虽然我的目的是将它完全放在我的屏幕上: enter image description here

请问我应该让我的xml看起来像是为了实现我的目标。感谢。

XML:

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

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

1 个答案:

答案 0 :(得分:1)

首先,您需要将方向设置为横向,因为您说您的目的是横向模式

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); // add it below super.oncreate

如果此代码无效,请查看此link

或者你可以在清单中设置方向只是google it

并在xml中更改此内容

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

<VideoView
    android:id="@+id/surface"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
/>
</FrameLayout>