9

It is possible to put any view over a VideoView? (I.e. put the control buttons over the video, like in vimeo). I'm trying to do it using FrameLayout, but I have not found the way, and I'm still not sure if what I'm trying to do something that's is simply not possible.

abarcia
  • 91
  • 1
  • 1
  • 3

1 Answers1

6

I do this sort of thing with FrameLayout. What you need to do is make sure that the controls are below the VideoView in the Layout Editor.

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

    <VideoView
        android:id="@+id/VideoView"
        android:layout_height="fill_parent"
        android:layout_width="fill_parent" />

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/ControlLayout"
        android:layout_gravity="bottom|center_horizontal">

        <Button
            android:text="@+id/Button01"
            android:id="@+id/Button01"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <Button
            android:text="@+id/Button02"
            android:id="@+id/Button02"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <Button
            android:text="@+id/Button03"
            android:id="@+id/Button03"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <Button
            android:text="@+id/Button04"
            android:id="@+id/Button04"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </LinearLayout>
</FrameLayout>
CaseyB
  • 24,780
  • 14
  • 77
  • 112
  • 4
    And if I use `setZOrderOnTop(true)` for the `VideoView` because it is a solution according to [this probelm](http://stackoverflow.com/questions/19650483/video-is-not-showing-on-videoview-but-i-can-hear-its-sound), how can I put views above it then? – Eido95 Oct 31 '16 at 21:48
  • that's correct, `setZOrderOnTop` will make the VideoView over everything, so how to solve that – Muhammed Refaat Jan 28 '18 at 13:14
  • @Eido95, did you find a solution for the case in which you use the `setZOrderOnTop` ? – Tiny Angel Jan 20 '23 at 07:00
  • 1
    @TinyAngel eventually, instead of `VideoView`, I wrote a custom view (I called it "ScreenView"). It is a `FrameLayout` which includes a `TextureView`. It's been 5 years since I used Android so there might be a better solution now. – Eido95 Jan 22 '23 at 14:33