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 8299835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:18:38+00:00 2026-06-08T16:18:38+00:00

I am writing a LiveWallpaper for Android and I want to have a Bitmap

  • 0

I am writing a LiveWallpaper for Android and I want to have a Bitmap with a certain amount of opacity to show.

In the constructor of my LiveWallpaper Engine I set a Paint that I will use later on my Canvas:

MyEngine() {
    ...
    mForeGroundPaint = new Paint();
    mForeGroundPaint.setAlpha(5);
}

I draw the Bitmap in this function, using the mForeGroundPaint on the drawBitmap():

void drawFrame() {
    final SurfaceHolder holder = getSurfaceHolder();
    Canvas c = null;
    try {
        c = holder.lockCanvas();
        if (c != null) {
            c.save();
            /* allows the wallpaper to scroll through the homescreens */
            c.drawBitmap(wpBitmap, screenWidth * -mOffset, 0,
                    mForeGroundPaint);
            c.restore();
        }
    } finally {
        if (c != null)
                 holder.unlockCanvasAndPost©;
    }
}

What happens now is, that everything seems to work fine, what means that the Bitmap is painted with the opacity value of 5, like I set it.

The problem happens when I use that drawFrame() function several times, as it is called during onOffsetsChanged(): The opacity sums up, making it 10, 15, 20, 25, … with every call of drawFrame().

How can I prevent that from happening, and thus keep the amount of opacity on a steady level?

  • 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-06-08T16:18:41+00:00Added an answer on June 8, 2026 at 4:18 pm

    The Bitmap is just being redrawn over old ones, so you have 2 Bitmaps at 5% opacity = 10% opacity. Try clearing the Canvas with c.drawColor(...); (with your background color) after c.save();.

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

Sidebar

Related Questions

Writing a dictionary application for android. Want to set translation direction in accord with
Writing a PHP app and have several classes that only have static methods (no
Writing a comparer, the numbers can be from 1-20. I have 2 hashtables that
Writing my first silverlight application. I need to deliver some bitmap that the customer
Writing htaccess that allows me to remove index.php from the URL can confuse search
Writing a test app to emulate PIO lines, I have a very simple Python/Tk
Writing documentation in html requires some code examples. What to do with characters that
Writing a client application that sends images to a server via a webservice. As
I'm currently writing a live wallpaper for Android and it has a PreferenceScreen which
Writing a lexer of .java source files in Java. I have a stream of

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.