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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:23:22+00:00 2026-06-01T21:23:22+00:00

Hello I would like to create a circular image witch has a small border

  • 0

Hello I would like to create a circular image witch has a small border and inside loads the users profile picture, just like google plus android application does.
The problem is that I need to set that image in as a drawable top of a Button, so I have found this code:

public BitmapDrawable putOverlay(Bitmap bitmap, Bitmap overlay) {
    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG);
    canvas.drawBitmap(overlay, 0, 0, paint);
    return new BitmapDrawable(bitmap);
} 

witch is supposed to overlay one bitmap (users pic) over another bitmap (oval shaped) but the think is that a) the circular bitmap is over the user’s profile pic, and b) the user’s profile pic is too large.
Any suggestions on how to do this or if I am at least on the right way is much appreciated.

UPDATE

I have managed to show the two images using this code:

public BitmapDrawable putOverlay(Bitmap bitmap, Bitmap overlay) {
    int width = overlay.getWidth()-50;
    int height = overlay.getHeight()-50;

    Bitmap b = Bitmap.createScaledBitmap(bitmap, width, height,true);
    Canvas canvas = new Canvas(overlay);
    canvas.save();
    canvas.translate(width,height);
    Matrix matrix = new Matrix();
    canvas.drawBitmap(overlay, matrix, null); 
    canvas.restore();
    canvas.drawBitmap(b,matrix, null);
    BitmapDrawable completeImage = new BitmapDrawable(getResources(),overlay);
    return completeImage;
}  

the problem is that the profile picture is not aligned into the circulare image.Its like the profile picture is drawn from the same x,y position the circulare image is drawn.
Also please note that the profile picture is loaded using :

bitmap = BitmapFactory.decodeStream((InputStream) new URL(imagepath).getContent());
  • 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-01T21:23:25+00:00Added an answer on June 1, 2026 at 9:23 pm

    Use this code (first scales the profile pic then applies the overlay)

    public BitmapDrawable putOverlay(Bitmap bitmap, Bitmap overlay) {
        Bitmap b = Bitmap.createScaledBitmap(bitmap, overlay.getWidth(), overlay.getHeight(),true);
        Canvas canvas = new Canvas(b);
        Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG);
        canvas.drawBitmap(overlay, 0, 0, paint);
        return new BitmapDrawable(b);
    } 
    

    I didn’t quite get what you meant in problem a that the overlay is on top of the profile pic

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

Sidebar

Related Questions

Hello I would like to create a Class which contains an array with the
hello i would like to know how would it be possible to create a
I would like to create the simplest (hello world package) package that I could
hello i have the following problem: i would like to create a filter for
Hello I would like to create a program that is based on the SIP
I am trying to create a Socket Hello World program. I would ideally like
I would like to create multiple progress bars inside a grid or table through
Hello I have a Problem with some Buttons I would like to create a
Hello I create jquery ui dialogs dynamically and would like to close them all
Hello I would like to use preg_match in PHP to parse the Desired text

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.