Search code examples
androidimageviewandroid-imageviewandroid-videoview

ImageView visible on the VideoView?


I would like to have the possibility to set visible an image in the imageview ( that occupies half screen) while playing a video in a videoview. It's possible to do that?


Solution

  • Create a xml like this,

    Add equal weight for the views and make there height 0dp, it will take equal height.

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        >
    
      <ImageView
          android:layout_width="match_parent"
          android:layout_height="0dp"
          android:layout_weight="1"
          android:background="#ccc"
          />
      <VideoView
          android:layout_width="match_parent"
          android:layout_height="0dp"
          android:layout_weight="1"
          />
    </LinearLayout>
    

    It will help you.