Android Snippet: Circle Image

20 Dec
December 20, 2012

A few months ago I was working on a project which required me to build a class that would download an image form the web, decode it, crop it, and show it in a circle – with a transparent background behind it, because it had to sit on top of different layout views.

I was only reminded of that seeing Romain Guy‘s blog post regarding images with rounded corners.

The end goal was to show the image just like an ImageView, only in a circle. This required me to extend a View and override the onDraw method to show it.

The circle part was tricky, so I thought I’d share that piece of code…

 

 

Tags: , , , , ,
2 replies
  1. Said Tahsin Dane says:

    Hi the code snippet is great and I am trying both yours and Romain Guy’s codes but I have a problem. I am putting this imageview to the bottom of another imageview. The background of these cirlce ImageViews are not transparent. How do I do that transparent? Thank you.

    Reply

Trackbacks & Pingbacks

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>