title: How to add a circle shape to an ImageView programmatically Android
body: <p>I want to add a circle black shape to the circle ImageView I have.</p>
  
  <p>I want something like this :</p>
  
  <p><a href="https://i.stack.imgur.com/MmFKx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MmFKx.png" alt="enter image description here"></a></p>
  
  <p>here is my code to make the ImageView circle :</p>
  
  <pre><code> private Bitmap getCircleBitmap(Bitmap bitmap) {
      final Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
              bitmap.getHeight(), Bitmap.Config.ARGB_8888);
      final Canvas canvas = new Canvas(output);
  
      final int color = Color.RED;
      final Paint paint = new Paint();
      final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
      final RectF rectF = new RectF(rect);
  
      paint.setAntiAlias(true);
      canvas.drawARGB(0, 0, 0, 0);
      paint.setColor(color);
      canvas.drawOval(rectF, paint);
  
      paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
      canvas.drawBitmap(bitmap, rect, rect, paint);
  
      bitmap.recycle();
  
      return output;
  }
  </code></pre>