Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6150119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:34:10+00:00 2026-05-23T19:34:10+00:00

I am new to Android development so have been picking things up over the

  • 0

I am new to Android development so have been picking things up over the past couple of months.

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.

The problem is that I am unsure what the correct method is to do this.

The code I originally wrote looks something like this:

  // 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 );
  }

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

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

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

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

So my question is really which is the correct method? Is one faster than the other?

Any thoughts would be appreciated.

🙂

Many thanks,
Wayne.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T19:34:11+00:00Added an answer on May 23, 2026 at 7:34 pm

    I’d say both do what they are supposed to be. Which one you choose really depends on your use-case. Do you need pixel-perfect placement? Do you have to redraw/alter the picture rather often at runtime? Use Canvas. Otherwise, the FrameLayout is more versatile and does not require any custom code to draw just two images.

    Im not sure speedwise, I’d say measure and see what you get. See this tutorial here, if you are new to Android you should read this. It’s useful to know in general.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am very new to android development and have been trying to draw a
I am new to Android development and I have a problem that I have
I'm quite new to Android development (started 2 days ago) and have been through
I am still pretty new to Android development, and I have not been able
I have been slowing learning and building my first android app. I'm VERY new
I am new to Android development and have been following the tutorials available on
I'm pretty new to Android app development, and I've been playing around with swipe
I am new to Java programming / Android development - but I have been
So I'm pretty new to android development and have been trying to piece together
I am new to Android layout development and have been tasked with designing and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.