title: Set background on SurfaceView
body: <p>I’m developing an Android drawing app, using a <code>SurfaceView</code> (to be more specific it’s a class that extends <code>SurfaceView</code>). I already saw a lot of topics on this forum, but I didn’t get my answer.<br /><br />
  My activity is basically a <code>FrameLayout</code>, which contains all of my views. I would like to set my <code>SurfaceView</code> on the lowest level of my <code>FrameLayout</code>, in order to see the upper elements (buttons, fragments, etc.). I also would like to set the background of my <code>SurfaceView</code> with a drawable but I’m facing problems.<br /><br />
  I tried first to set the background of my <code>SurfaceView</code> itself and it works. Unfortunately, my painting content (canvas and bitmap) was overload by this background so I tried a second solution. I apply the drawable background to my <code>FrameLayout</code>, and I set my <code>SurfaceView</code> background as transparent, using <code>setZOrderOnTop</code>. My <code>SurfaceView</code> was indeed transparent, but my drawing stuff was above my buttons and fragments.<br /><br />
  So my first question is: why do we need to <code>setZOrderOnTop</code> to get a transparent background? Then, how can I set a simple drawable background, keeping my structure hierarchy?<br /><br />
  Thank’s for your answers!</p>
  
  <p><strong>XML View:</strong></p>
  
  <pre><code>&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/mainFrame"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@drawable/repeat_background"
      tools:context=".MyActivity"&gt;
  
      &lt;!-- Option menu --&gt;
      &lt;fragment ... /&gt;
      &lt;Button ... /&gt;
      &lt;Button ... /&gt;
      &lt;Button ... /&gt;
  
      ...
  
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <p><strong>@drawable/repeat_background</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;bitmap xmlns:android="http://schemas.android.com/apk/res/android"
      android:src="@drawable/drawing_font_texture"
      android:tileMode="repeat" /&gt;
  </code></pre>
  
  <p><strong>MyActivity</strong></p>
  
  <pre><code>@Override
  protected void onCreate(Bundle p_savedInstanceState) {
      super.onCreate(p_savedInstanceState);
      setContentView(R.layout.main_controller_activity);
  
      // Getting my FrameLayout
      FrameLayout mainFrame   = (FrameLayout) findViewById(R.id.mainFrame);
  
      // Instantiating my SurfaceView
      this.drawableView       = new MCustomDrawableView(getApplicationContext());
  
      // Don't works
      //setZOrderMediaOverlay(true);
  
      this.drawableView.setZOrderOnTop(true);
      this.drawableView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
  
      FrameLayout.LayoutParams style = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
              FrameLayout.LayoutParams.MATCH_PARENT);
  
  
      // Add the SurfaceView to the FrameLayout, on lowest position
      mainFrame.addView(this.drawableView, 0, style);
  }
  </code></pre>