Android VideoView作为背景

时间:2015-02-20 10:06:11

标签: android android-fragments layout android-videoview

我会在我的布局中使用VideView作为背景。

所以我想将此视频全屏显示,我需要在此视图中添加其他组件'像TextView,EditView,ImageView ......等。

这是我的代码示例:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent"  tools:context=".Login"
    android:alpha="0.9">

    <VideoView
        android:scrollbars="none"
        android:clickable="false"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_gravity="center"
        android:id="@+id/VideoView">
    </VideoView>

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
        android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:alpha="0.9">

    <ImageView
        android:id="@+id/imageView1"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="15dip"
        android:layout_width="130dp"
        android:layout_height="100dp"
        android:alpha="0.7"
        android:src="@drawable/logoweb"/>

etc...

通过这种方式,我无法看到其他组件......只有视频...

1 个答案:

答案 0 :(得分:1)

尝试使用FrameLayout。

FrameLayout总是把东西放在另一个上面并始终引用左上角,你可以用这样的东西来实现上面的结果

<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<VideoView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:id="@+id/VideoView"

    />
<ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|center"
    android:alpha="0.7"
    android:src="@drawable/logoweb"
    />