Skip to content
Related Articles

Related Articles

How to create a Circular image view in Android without using any library?

View Discussion
Improve Article
Save Article
Like Article
  • Difficulty Level : Medium
  • Last Updated : 07 Aug, 2021

This article aims to help in how to make a circular image view on an image using the Android App. A simple circular image view can be made with white border and transparent content with shape without using any library. 

Below are steps on how to do so: 

  • Step 1: Creating the layout of the circular image view 
    Create a new drawable resource file in the drawable directory which defines the shape of image view that is a circle.

Here filename is circular.xml


<?xml version="1.0" encoding="utf-8"?>
 <!--defines the circular shape and its properties-->
    android:useLevel="false" >
        android:color="@android:color/transparent" />
        android:color="@android:color/white" />

  • Step 2: Next step is to make a layerlist drawable so that it can act as background to your imageview. Create a new XML file in drawable directory with name image.xml

Here filename is image.xml


<?xml version="1.0" encoding="utf-8"?>
<!--define layer-list-->
    <!--set image to be shown on circular image view-->
    <item android:drawable="@drawable/ic_launcher"/>
    <item android:drawable="@drawable/circular"/>

  • Step 3: Creating the activity_main.xml


<?xml version="1.0" encoding="utf-8"?>
  <!--put image.xml as background to your image view-->

  • Step 4: Creating the backend file


package com.geeksforgeeks.circularimageview;
public class MainActivity extends AppCompatActivity {
    ImageView imageView;
    protected void onCreate(Bundle savedInstanceState)
        ActionBar actionBar;
        actionBar = getSupportActionBar();
        ColorDrawable colorDrawable
            = new ColorDrawable(
                 "Circular Image View "
                     + "without using any library",

Output: Circular image view 

Activity containing Circular image


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!