• Stars
    star
    1,944
  • Rank 22,824 (Top 0.5 %)
  • Language
    Kotlin
  • License
    Apache License 2.0
  • Created almost 11 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Create circular ImageView in Android in the simplest way possible

CircularImageView

sample

Platform API Maven Central Twitter

This is an Android project allowing to realize a circular ImageView in the simplest way possible.

Android app on Google Play

USAGE

To make a circular ImageView add CircularImageView in your layout XML and add CircularImageView library in your project or you can also grab it via Gradle:

implementation 'com.mikhaellopez:circularimageview:4.3.1'

XML

<com.mikhaellopez.circularimageview.CircularImageView
    android:layout_width="250dp"
    android:layout_height="250dp"
    android:src="@drawable/image"
    app:civ_border_color="#3f51b5"
    app:civ_border_width="4dp"
    app:civ_shadow="true"
    app:civ_shadow_radius="10dp"
    app:civ_shadow_color="#3f51b5"/>

You must use the following properties in your XML to change your CircularImageView.

Properties Type Default
app:civ_circle_color color WHITE
app:civ_circle_color_start color civ_circle_color
app:civ_circle_color_end color civ_circle_color
app:civ_color_direction left_to_right, right_to_left, top_to_bottom or bottom_to_top left_to_right
app:civ_border boolean true
app:civ_border_width dimension 4dp
app:civ_border_color color WHITE
app:civ_border_color_start color civ_border_color
app:civ_border_color_end color civ_border_color
app:civ_border_color_direction left_to_right, right_to_left, top_to_bottom or bottom_to_top left_to_right
app:civ_shadow boolean false
app:civ_shadow_color color BLACK
app:civ_shadow_radius dimension 8dp
app:civ_shadow_gravity center, top, bottom, start or end bottom

โ„น๏ธ You can also use android:elevation instead of app:civ_shadow to have default Material Design elevation.

KOTLIN

val circularImageView = findViewById<CircularImageView>(R.id.circularImageView)
circularImageView.apply {
    // Set Color
    circleColor = Color.WHITE
    // or with gradient
    circleColorStart = Color.BLACK
    circleColorEnd = Color.RED
    circleColorDirection = CircularImageView.GradientDirection.TOP_TO_BOTTOM

    // Set Border
    borderWidth = 10f
    borderColor = Color.BLACK
    // or with gradient
    borderColorStart = Color.BLACK
    borderColorEnd = Color.RED
    borderColorDirection = CircularImageView.GradientDirection.TOP_TO_BOTTOM
    
    // Add Shadow with default param
    shadowEnable = true
    // or with custom param
    shadowRadius = 7f
    shadowColor = Color.RED
    shadowGravity = CircularImageView.ShadowGravity.CENTER
}

JAVA

CircularImageView circularImageView = findViewById(R.id.circularImageView);
// Set Color
circularImageView.setCircleColor(Color.WHITE);
// or with gradient
circularImageView.setCircleColorStart(Color.BLACK);
circularImageView.setCircleColorEnd(Color.RED);
circularImageView.setCircleColorDirection(CircularImageView.GradientDirection.TOP_TO_BOTTOM);

// Set Border
circularImageView.setBorderWidth(10f);
circularImageView.setBorderColor(Color.BLACK);
// or with gradient
circularImageView.setBorderColorStart(Color.BLACK);
circularImageView.setBorderColorEnd(Color.RED);
circularImageView.setBorderColorDirection(CircularImageView.GradientDirection.TOP_TO_BOTTOM);

// Add Shadow with default param
circularImageView.setShadowEnable(true);
// or with custom param
circularImageView.setShadowRadius(7f);
circularImageView.setShadowColor(Color.RED);
circularImageView.setShadowGravity(CircularImageView.ShadowGravity.CENTER);

LIMITATIONS

  • By default the ScaleType is FIT_CENTER. You can also used CENTER_INSIDE AND CENTER_CROP.
  • Enabling adjustViewBounds is not supported as this requires an unsupported ScaleType.

SUPPORT โค๏ธ

Find this library useful? Support it by joining stargazers for this repository โญ๏ธ
And follow me for my next creations ๐Ÿ‘

LICENCE

CircularImageView by Lopez Mikhael is licensed under a Apache License 2.0.

More Repositories

1

CircularProgressBar

Create circular ProgressBar in Android โญ•
Kotlin
1,683
star
2

CircularFillableLoaders

Realize a beautiful circular fillable loaders to be used for splashscreen ๐ŸŒŠ
Java
1,220
star
3

BestAndroidGists

Find best Android Gist ๐Ÿ”ฅ
884
star
4

RxAnimation

Simple way to animate your views on Android with Rx ๐Ÿš€
Kotlin
594
star
5

AndroidWebServer

Android Web Server (NanoHttpd)
Java
434
star
6

CleanRxArchitecture

Clean Rx Kotlin Architecture sample on GitHub Api ๐Ÿš€
Kotlin
386
star
7

LazyDatePicker

LazyDatePicker an alternative to the native Android Date Picker ๐Ÿ“…
Java
372
star
8

RateBottomSheet

To help to promote your android app by prompting users to rate your app in a BottomSheet โญ๏ธ
Kotlin
307
star
9

GradientView

Create gradient view in Android in the simplest way possible ๐ŸŒˆ
Kotlin
198
star
10

HFRecyclerView

Add Header and/or Footer in your RecyclerView in the simplest way possible.
Kotlin
171
star
11

CircleView

Create circular view in android (change color, border & shadow) โšซ
Kotlin
166
star
12

Biometric

The easiest way is to use the new version of Biometric under AndroidX ๐Ÿ”’
Kotlin
141
star
13

PokeCardCompose

PokeCard Compose is a demo app 100% write in Compose, Flow and Koin based on MVI Clean Architecture ๐Ÿฑโšก๏ธ
Kotlin
114
star
14

SaveInsta

Example dynamic update of your theme based on a main color
Java
85
star
15

AutoScrollTextView

Sample Android application show how to set auto scroll in text view in android.
Java
51
star
16

FavoriteAndroidLibrary

My Farorite Android Library
49
star
17

MyToast

Custom Toast on Android
Java
39
star
18

DualShot

With DualShot you take two photos with the front and the back camera, and share both of them in a single image.
Java
23
star
19

WebSideMVC

Structure MVC for Web Side in PHP
PHP
1
star