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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:31:23+00:00 2026-06-15T10:31:23+00:00

My question has to do with applying an image overlay to all button pressed

  • 0

My question has to do with applying an image overlay to all button pressed events. So, for example, in Android 4.0 and higher with the holo setup, when you press any button, it has the light blue overlay on the button. In the earlier version of android, it is orange. I know how to setup the button to change the image for pressed, focused, and default in the XML with the selector and item tags, but that would require me to make another image of my button but with a light blue overlay which means i know have 2 pictures for every button. My app is going to have a lot of buttons, and i’d like to keep the file size of the app as small as possible.

So the point of the question is, is there a way to make just 1 picture (the light blue 25% opacity image) apply as an overlay to all button presses while also keeping the original background of the button I had set stay there?

  • 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-15T10:31:24+00:00Added an answer on June 15, 2026 at 10:31 am

    Load in the image. Then draw the alpha color ontop of it.

    Then use the modified image to set the button Image.

    Bitmap img = BitmapFactory.decodeFile(pathName); // or decodeResource  etc....
    
    Canvas canvas = new Canvas(img);
    Paint alphaPaint = new Paint();
    
    // Color to apply.
    alphaPaint.setColor(Color.BLUE);
    alphaPaint.setAlpha(20);
    
    // Draw rectangle over your image using the alpha colored paint.
    canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), alphaPaint);
    myButton.setImageBitmap(img );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi all I know that this has been posted as a prior question several
Well the question is, I have got a column, for example column Y has
This question has developed off an answer here . My question therefore is what
This question has two parts. Part 1. Yesterday I had some code which would
My question has two parts: Is it possible that, if a segfault occurs after
This question has been asked before but i still don't understand it fully so
this question has probably been asked before, but i'm stuck and i've tried a
This question has baffled myself and my cohorts. In the program I had written
This question has disturbed me for a long time. Sorry if it is a
This question has been bugging me for a long time now but essentially I'm

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.