Android button to appear on video view

4.4k Views Asked by At

How can i get the button to be on top of the video view instead of above it? Here's the code:

<?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"
android:orientation="vertical" 
>

<Button
    android:id="@+id/btnHD"
    style="@style/btnStyleGenoa"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Turn HD On" />

<VideoView
    android:id="@+id/videoView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal" />
</LinearLayout>

Many Thanks

3

There are 3 best solutions below

0
On BEST ANSWER

you can simply use this:

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

<VideoView
    android:id="@+id/videoView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal" />

<Button
    android:id="@+id/btnHD"
    style="@style/btnStyleGenoa"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_marginBottom="17dp"
    android:text="Turn HD On" />

2
On

use below

<?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" 
>
<Button
    android:id="@+id/btnHD"
    style="@style/btnStyleGenoa"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Turn HD On" />

<VideoView
    android:id="@+id/videoView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal" />



 </RelativeLayout >

Enjoy :)

0
On

Sanket is right.I will tell you how it works. The view which is written last in Relative layout is the toppest view of that layout(z-axis)