title: Compositing Android MapView and SurfaceView
body: <p>I have an application with a SurfaceView and a MapView. They are displayed in a single view, like so:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/mainlayout"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent" &gt;
  
      &lt;com.google.android.maps.MapView
          android:id="@+id/mapview"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:clickable="true"
          android:apiKey="XXXXXXXXredactedXXXXXXXXXXXXx"
      /&gt;
  
  &lt;class.that.extends.SurfaceView
      android:id="@+id/surfaceview"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:background="#00000000"
      /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Note the MapView comes before the SurfaceView. Because of this, the MapView is drawn "under" the SurfaceView, and all that I see is a black background, with the things that I draw on the SurfaceView showing. If I swap the order, and put SurfaceView first in the file and MapView second, the MapView is drawn, with none of the SurfaceView showing. </p>
  
  <p>According to the <a href="http://developer.android.com/reference/android/view/SurfaceView.html" rel="nofollow">SurfaceView Javadoc</a>:</p>
  
  <blockquote>
    <p>The surface is Z ordered so that it is behind the window holding its SurfaceView; the SurfaceView punches a hole in its window to allow its surface to be displayed. The view hierarchy will take care of correctly compositing with the Surface any siblings of the SurfaceView that would normally appear on top of it.</p>
  </blockquote>
  
  <p>To me, this means that I should be able to put the SurfaceView first in the file, and have it "punch through" the MapView and display what it has. But, as it is, they seem to be two views, and only one is visible at a time.</p>
  
  <p>After thought: I tried setting the background to #00000000 so that the alpha of the background would be zero (i.e. transparent), but it doesn't have any effect.</p>