Safari
Safari

Reputation: 11935

Android VideoView as background

I would to use a VideView as background in my layout.

So I would to have this videoView fullscreen and I need to add on this view other 'components' like TextView, EditView, ImageView...etc.

This is an example of my code:

<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...

In this way I can't see the other components... only the video...

Upvotes: 0

Views: 1921

Answers (1)

Arslan Sohail
Arslan Sohail

Reputation: 1713

Try using FrameLayout.

FrameLayout always places things one on top of the other and always in reference to the upper lefthand corner,you can use something like this to acheive the above result

<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"
    />

Upvotes: 1

Related Questions