How to create CircularImageView in android?

AndroidMobile DevelopmentProgramming

This example demonstrate about how to Create CircularImageView in android.

Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.

Step 2 −To make circler view, we should add CircularImageView library in gradle file as shown below.

apply plugin: ''
android {
   compileSdkVersion 28
   defaultConfig {
      applicationId "com.example.andy.myapplication"
      minSdkVersion 15
      targetSdkVersion 28
      versionCode 1
      versionName "1.0"
      testInstrumentationRunner ""
   buildTypes {
      release {
         minifyEnabled false
         proguardFiles getDefaultProguardFile('proguard-android.txt'), ''
dependencies {
   implementation fileTree(dir: 'libs', include: ['*.jar'])
   implementation ''
   implementation ''
   testImplementation 'junit:junit:4.12'
   androidTestImplementation ''
   implementation 'com.mikhaellopez:circularimageview:3.2.0'
   androidTestImplementation ''

Step 3  − Following is the content of the modified main activity file This file can include each of the fundamental life cycle methods. We have created a CircularImageView in activity_main.xml

import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
   protected void onCreate(Bundle savedInstanceState) {

Step 4 − Following will be the content of res/layout/activity_main.xml file to include a CircularImageView.

<?xml version = "1.0" encoding = "utf-8"?>
< xmlns:android = ""
xmlns:app = ""
   xmlns:tools = ""
   android:layout_width = "match_parent"
   android:layout_height = "match_parent"
   tools:context = ".MainActivity">
   android:layout_width = "match_parent"
   android:gravity = "center_horizontal"
   android:orientation = "vertical"
   android:layout_height = "match_parent">
      android:layout_width = "250dp"
      android:layout_height = "250dp"
      android:src = "@drawable/image"
      app:civ_border_color = "#EEEEEE"
      app:civ_border_width = "4dp"
      app:civ_shadow = "true"
      app:civ_shadow_radius = "10"
      app:civ_shadow_color = "#8BC34A"/>
      android:text = "Mohammad Mohtashim"
      android:layout_width = "match_parent"
      android:layout_height = "match_parent"
      android:layout_marginTop = "20dp"
      android:textSize = "20sp"
      android:textAlignment = "center"/>

The above layout we have declared CircularImageView as com.mikhaellopez.circularimageview.CircularImageView and added image from drawable as id is image.

Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from android studio, open one of your project's activity files and click Run Play icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen −


Properties of CircularImageView

  • app:civ_border  − This property is used to create border and default value is true

  • app:civ_border_color − This property is used to create border color and default color is white

  • app:civ_border_width − This property is used to create border width and default value is 4dp

  • app:civ_background_color − This property is used to create background color and default background color is white

  • app:civ_shadow − This property is used to create shadow for image and default value is false, if required shadow we need to make true

  • app:civ_shadow_color − This property is used to create shadow color for image and default value is black

  • app:civ_shadow_radius − This property is used to create shadow radius for image and default value is 8.0f

  • app:civ_shadow_gravity − This property is used to create shadow gravity for image and default value is bottom.

Click here to download the project on this topic.

Updated on 30-Jul-2019 22:30:23