Search code examples
androidandroid-layoutsurfaceviewglsurfaceview

How to put a transparent view on another Layout


I am working on Surface view. I want one transparent view on my surface view. That transparent view must consist of three things Title, Description and Spinner and one button name "Start". Without entering the title, description and Spinner's menu one cannot go the next layout which is below that transparent view. Please help me to with some sort of examples.. How to achieve such kind of view??? This is what I want.. enter image description here

This is My Surfaceview layout..

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


<LinearLayout
    android:id="@+id/suface_view_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">


    <net.ossrs.yasea.SrsCameraView
        android:id="@+id/glsurfaceview_camera"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true" />

</LinearLayout>

Solution

  • Use FrameLayout instead of RelativeLayout

     <?xml version="1.0" encoding="utf-8"?>
     <FrameLayout 
      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=".MainActivity">
    
      // Add other view
    
     <LinearLayout
      android:id="@+id/suface_view_layout"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical">
    
    
      <net.ossrs.yasea.SrsCameraView
        android:id="@+id/glsurfaceview_camera"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true" />
    
     </LinearLayout>
    
     </FrameLayout>