Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

How to Create Circular ImageView in Android using CardView?

  • Difficulty Level : Expert
  • Last Updated : 18 Feb, 2021

Displaying an Image in Android is done easily using ImageView., But what if one wants to display a circular image? It is seen that many Android apps use CircularImageView to show the profile images, status, stories, and many other things but doing this with a normal ImageView is a bit difficult. This article will help to create a circular image using CardView. Through cardCornerRadius one can customize the corner of the ImageView. A sample image is given below to get an idea about what we are going to create in this article. Note that we are going to implement this project using the Java language.

Sample image


One may perform the same operation in another two methods. Please refer to the link below.


Step 1: Create a New Project

To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. Note that select Java as the programming language.

Step 2: Add dependency to the build.gradle file

 Go to build.gradle file and add this dependency and click on Sync Now button.

implementation ‘androidx.cardview:cardview:1.0.0’

Step 3: Working with the activity_main.xml file

Next, go to the activity_main.xml file, which represents the UI of the project. Below is the code for the activity_main.xml file. Comments are added inside the code to understand the code in more detail.

Note: Change android:src=”@drawable/your_image” to your Image name


<?xml version="1.0" encoding="utf-8"?>
    <!-- Using CardView for CircularImageView -->
        <!-- add a Image image.png in your Drawable folder -->
            android:src="@drawable/circular" />
        android:text="Circular ImageView"
        android:textStyle="bold" />

Step 4: Working with the file

Finally, go to the MainActivity.kt file, and refer to the following code. Below is the code for the MainActivity.kt file. We have added a Toast message only. It Toasts a message as you click on the Image.


import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
    ImageView imageView;
    protected void onCreate(Bundle savedInstanceState) {
        imageView = (ImageView) findViewById(;
        imageView.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Toast.makeText(MainActivity.this, "This is a Circular ImageView", Toast.LENGTH_SHORT).show();



My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!