anoop44 / CircularImageView

Create circular ImageView in Android in the simplest way possible

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CircularImageView

sample

Platform API Download
Twitter Codacy Badge

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.0.2'

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="10"
    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_border boolean true
app:civ_border_width dimension 4dp
app:civ_border_color color WHITE
app:civ_shadow boolean false
app:civ_shadow_color color BLACK
app:civ_shadow_radius float 8.0f
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 Circle color for transparent image
    circleColor = Color.WHITE
    // Set Border
    borderColor = Color.RED
    borderWidth = 10f
    // Add Shadow with default param
    shadowEnable = true
    // or with custom param
    shadowRadius = 15f
    shadowColor = Color.RED
    shadowGravity = CircularImageView.ShadowGravity.CENTER
}

JAVA

CircularImageView circularImageView = findViewById(R.id.circularImageView);
// Set Circle color for transparent image
circularImageView.setCircleColor(Color.WHITE);
// Set Border
circularImageView.setBorderColor(Color.RED);
circularImageView.setBorderWidth(10);
// Add Shadow with default param
circularImageView.setShadowEnable(true);
// or with custom param
circularImageView.setShadowRadius(15);
circularImageView.setShadowColor(Color.RED);
circularImageView.setBackgroundColor(Color.RED);
circularImageView.setShadowGravity(CircularImageView.ShadowGravity.CENTER);

LIMITATIONS

  • By default the ScaleType is CENTER_CROP. You can also used CENTER_INSIDE but the others one are not supported.
  • 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.

About

Create circular ImageView in Android in the simplest way possible

License:Apache License 2.0


Languages

Language:Kotlin 100.0%