How to make Circular ImageView and Rounded Corner ImageView in Android

How to make Circular ImageView and Rounded Corner ImageView in Android

In this tutorial we are going to learn different ways to make circular ImageView and rounded corner ImageView in android. The default ImageView in android is rectangle so there are situations where we will like to create a circular ImageView or rounded corner ImageView in android.

This will be a simple tutorial but its important cannot be undermined when it comes to designing a visually attractive and elegant application in android.

There are different ways to achieve this but before I went further I will like us to see a sample of what we are to achieve. The image below represent a circular and rounded corner ImageView in android application.

How to make Circular ImageView and Rounded Corner ImageView in Android

We will first create a class that we can use to change or adjust the amount of rounded corner we wanted in our ImageView. This class can be use to create both circular and rounded corner ImageView.

Secondly, we will look into a simple library that we will add in our project which will help us to achieve the same result with less code.

Before we start, the first thing I will do is to list the environment and tools I used in this android tutorial but feel free to use whatever environment or tools you are familiar with.

Windows 7

Android Studio

Sony Xperia ZL

Min SDK 14

Target SDK 19

To create a new android application project, following the steps as stipulated below.

Go to File menu

Click on New menu

Click on Android Application

Enter Project name: AndroidCircularImageView

Package: com.inducesmile.androidcircularimageview

Keep other default selections.

Continue to click on next button until Finish button is active, then click on Finish Button

Once you are done with creating your project, make sure you change the package name if you did not use the same package.

We will create image helper class called ImageCreator which will contain a single static method that will accept a Bitmap object and number of pixel for rounded corner as parameters. The code sample is shown below.



/*adopted from*/

public class ImageConverter {

    public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) {
        Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(output);

        final int color = 0xff424242;
        final Paint paint = new Paint();
        final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
        final RectF rectF = new RectF(rect);
        final float roundPx = pixels;

        canvas.drawARGB(0, 0, 0, 0);
        canvas.drawRoundRect(rectF, roundPx, roundPx, paint);

        paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
        canvas.drawBitmap(bitmap, rect, rect, paint);

        return output;

We will convert our image resource in drawable folder and convert it to a bitmap using BitmapFactory class. The Bitmap object is then passed to the static method getRoundedCornerBitmap(Bitmap bitmap, int pixels)  and the result bitmap is set to the ImageView.

In our project main activity layout (activity_main.xml), one ImageView and one custom ImageView components are added to the layout file as shown in the code.

<RelativeLayout xmlns:android=""

        android:layout_marginTop="24dp" />



The custom ImageView called CircularImageView is added in the project by add a dependency in the project build.gradle file as shown below.

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile ''
    compile 'de.hdodenhof:circleimageview:1.2.1'

It help use to use this external library in our application. We will around assign the android:src property with an image resource.

Our file is very simple and I have explain what the codes are doing. The complete code for the class is as shown.


import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ImageView;

public class MainActivity extends ActionBarActivity {

    protected void onCreate(Bundle savedInstanceState) {

        Bitmap bitmap = BitmapFactory.decodeResource(this.getResources(),R.drawable.circularimage);
        Bitmap circularBitmap = ImageConverter.getRoundedCornerBitmap(bitmap, 100);

        ImageView circularImageView = (ImageView)findViewById(;


    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(, menu);
        return true;

    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == {
            return true;

        return super.onOptionsItemSelected(item);

Save the file and run your project.

You can download the code for this tutorial below. If you are having hard time downloading the tutorials, kindly contact me.

Remember to subscribe with your email so that you will be among the first to receive our new post once it is published


  1. Avatar
    • Inducesmile
  2. Avatar
  3. Avatar

Add a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

50% Discounts On Projects

Do you have a custom project with a clear requirements, we are currently giving a 50% discount on all projects.

We will work with you to ensure we deliver what you need.

If you have questions or want to chat with us, you can reach us on Skype (henry.tochi)

Languages and technologies we use - Java, Kotlin, Laravel, Vue, React, Flutter, Swift and more.