What is the best/correct way to overlay images
<p>I am new to Android development so have been picking things up over the past couple of months. </p>

<p>The app that I am writing requires 2 images to be displayed, one of top of the other. The image on top has some transparent areas where I want the image below to appear.</p>

<p>The problem is that I am unsure what the correct method is to do this.</p>

<p>The code I originally wrote looks something like this: </p>

<pre><code>  // background worker thread Run() method
  Canvas canvas = null;
  try
  {
    canvas = _surfaceHolder.lockCanvas(null);
    synchronized( _surfaceHolder )
    {
      canvas.drawBitmap( _backgroundBitmap, 0, 0, null );
      // ...
      canvas.drawBitmap( _foregroundBitmap, 0, 0, null );
    }
  }
  finally
  {
    if( canvas != null )
      _surfaceHolder.unlockCanvasAndPost( canvas );
  }
</code></pre>

<p>Although this works, I have since read about how the same thing can be achieved using an ImageView <strong>positioned on top of the view</strong> associated with the app in the main activites layout xml file:</p>

<pre><code>&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"&gt;

    &lt;!-- This is the surface where the application is responsible for drawing to --&gt;
    &lt;com.test.MainAppView
        android:id="@+id/mainView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        /&gt;

    &lt;!-- 
    This is where a foreground graphic could be displayed which allows me
    to remove the drawBitmap() code from the Run() method shown above.
    --&gt;
    &lt;ImageView
        android:id="@+id/foregroundgraphic"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        /&gt;
&lt;/FrameLayout&gt;
</code></pre>

<p>So my question is really which is the correct method? Is one faster than the other?</p>

<p>Any thoughts would be appreciated.</p>

<p>:-)</p>

<p>Many thanks,
Wayne.</p>
