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

  • Home
  • SEARCH
  • 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 4014176
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:27:54+00:00 2026-05-20T09:27:54+00:00

I am hoping the saveLayer methods will allow me to do draw onto different

  • 0

I am hoping the saveLayer methods will allow me to do draw onto different “layers” and then once the drawing has finished, merge the layers with the canvas in whichever order i choose.

The obvious question is “why dont you just rearrange your drawing operations instead?” The answer is I can’t:

I have a Path that I need to draw onto a Canvas. In the background/lowest z-index I want to draw the path closed and with a few additional points using a fill style. Then on top of that, I want to draw an outline of only the points that were originally in the Path.

Since I cannot undo the adding of points to the Path, my only choices are to clone the path, or to draw to a second layer which can later be placed on top of everything else.

saveLayer() seems to offer that functionality but it doesnt behave the way I was expecting. The basic flow of my operations is like this:

int overlay = canvas.saveLayer(...);
// drawing operations for my uppermost layer
...

int background = canvas.saveLayer(...);
// drawing operations for my background layer
...

// merge the offscreen background bitmap with the canvas:
canvas.restoreToCount(background);

// merge the offscreen overlay bitmap with the canvas:
canvas.restoreToCount(overlay);

When the code runs, the ordering of background and overlay have not changed at all; what gets drawn first is at the bottom and what gets drawn last is on top. Even stranger to me is that I can completely comment out both calls to restoreToCount() and nothing changes. According to the javadoc, nothing should be drawn to the canvas until a balancing restore() is invoked.

Obviously I am completely misunderstanding the function of this method. Can anybody help me to understand saveLayer’s usage, or perhaps suggest an alternate way to layer my drawing operations?

Thx!
Nick

  • 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-20T09:27:55+00:00Added an answer on May 20, 2026 at 9:27 am

    saveLayer() does not let you rearrange the layers in a random order. The only way to do it is to draw in offscreen bitmaps yourself. Note also that your view’s parent will call save()/restore() around your onDraw() call, which will cause your layers to be composited.

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

Sidebar

Related Questions

I'm hoping someone has seen this before because I can't for the life of
I'm hoping that someone has found a way of doing this already or that
Hoping someone has ran into this scenario and can lead me in the right
Hoping this will be a simple one, in Sketchflow i'm trying to wire up
Hoping someone can provide an answer with this, although it's not 100% programming related.
I'm hoping there's a way to avoid custom configuration files if an application runs
I'm hoping to find out what tools folks use to synchronize data between databases.
I am hoping to find a way to do this in vb.net: Say you
I'm hoping there's something in the same conceptual space as the old VB6 IsNumeric()
I was hoping to implement a simple XMPP server in Java. What I need

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.