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. So to do so use hdodenhof CircleImageView Library. It’s a fast circular ImageView perfect for profile images. This is based on RoundedImageView from Vince Mi. So in this article, let’s add a CircleImageView in the Android App. A sample image is given below to get an idea about what we are going to do in this article.
Note: To create a CircularImageView in Android without using any library please refer to How to create a Circular image view in Android without using any library?
Steps for Creating a CircularImageView
Step 1: Creating 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 choose Java as language though we are going to implement this project in Java language.
Step 2: Before going to the coding section first do some pre-task
- Go to Gradle Scripts -> build.gradle (Module: app) section and import the following dependencies and click the “sync Now” on the above pop up.
Step 3: Designing the UI
- Create a CircleImageView inside the activity_main.xml file and set the android:src=”@drawable/mountain”. The complete code of the activity_main.xml file is given below.
Step 4: MainActivity.java file
Here in this project there is nothing to do with the MainActivity.java file, so keep it as it is.
- In this library, the ScaleType is always CENTER_CROP and you will get an exception if you try to change it.
- Enabling adjustViewBounds is not supported as this requires an unsupported ScaleType.
- Using a TransitionDrawable with CircleImageView doesn’t work properly and leads to messed-up images.
Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.
- How to Add OpenCV library into Android Application using Android Studio?
- How to create a Circular image view in Android without using any library?
- How to create popup message using Alerter Library in android
- How to add Cutsom Switch using IconSwitch Library in android?
- Android | How to Create/Start a New Project in Android Studio?
- How to create a CalendarPickerView using TimeSquare library
- How to Create AlertDialog Box Using SweetAlert Dialog Library?
- Image loading and caching library for Android | Set 1
- Image loading and caching library for Android | Set 2
- Volley Library in Android
- How to add Slidr Library in Android?
- How to install Android Applications in Mobile Phone without USB Cables using Android Studio
- How to implement Swipe Down to Refresh in Android using Android Studio
- How to create a Facebook login using an Android App?
- How to create a Stopwatch App using Android Studio
- How to create a Face Detection Android App using Machine Learning KIT on Firebase
- How to Create a Color Picker Tool in Android using Color Wheel and Slider?
- How to Create Circular ImageView in Android using CardView?
- How to Create a Splash Screen in Android using Kotlin?
- Android | AdMob Banner Ads for Android Studio
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.