How to set circular background color in CircleImageView


We often need to set the background colour of an image and for that we use

But in case of CircleImageView, when we use setBackgroundColor() function it sets the background colour in a quadrilateral shape.

To set a circular background colour behind a CircularImageView you can use

As we can see void setColorFilter (int colour,PorterDuff.Mode mode) need two parameters a colour and Porter-Duff mode to be the colour filter for a drawable. This function actually combines images as per the user’s requirements.


The color is the background colour we want and Porter-Duff.mode defines the way of combining images.


For the first parameter, if you want to generate a random colour you can use the below code segment


And for the second parameter, there are several Porter-Duff.mode which can be used for combining images like DST_ATOP, SRC_ATOP, DST_IN, DST_OUT etc. The image below provide good understanding of some of the modes




. . .

Leave a Comment

Your email address will not be published. Required fields are marked*

Be the first to comment.


It was a successful collaboration. The Mobikul team provided the client everything they needed in a timely and high-quality manner. They were very professional, reliable, and accessible during the entire process. The client also saw no room for any improvements in the vendor's performance.

Vincenzo Carrano

Vincenzo Carrano

Administrator, Segshop

Talk to Sales


Live Chat
Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home