Top Related Projects
A circular ImageView for Android
Custom shaped android imageview components
Custom view for circular images in Android while maintaining the best draw performance
A library for supporting custom shaped ImageView(s) using SVGs and paint shapes
A fast ImageView that supports rounded corners, ovals, and circles.
Give a custom shape to any android view, Material Design 2 ready
Quick Overview
CircularImageView is an Android library that provides a custom ImageView for displaying circular images. It offers a simple and efficient way to create circular image views with optional border and shadow effects, making it easy to implement rounded profile pictures or circular image thumbnails in Android applications.
Pros
- Easy to implement with minimal setup required
- Supports both XML and programmatic creation
- Offers customizable border and shadow effects
- Efficient performance with hardware acceleration
Cons
- Limited to circular shape only (no support for other shapes)
- May not be necessary for newer Android versions with built-in shape support
- Lacks advanced features like touch feedback or animation support
Code Examples
Creating a CircularImageView in XML:
<com.mikhaellopez.circularimageview.CircularImageView
android:layout_width="250dp"
android:layout_height="250dp"
android:src="@drawable/your_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"/>
Creating a CircularImageView programmatically:
val circularImageView = CircularImageView(context).apply {
borderWidth = 10f
borderColor = Color.WHITE
shadowEnable = true
shadowRadius = 15f
shadowColor = Color.RED
setImageResource(R.drawable.your_image)
}
Applying a color filter to the CircularImageView:
circularImageView.setColorFilter(Color.RED, PorterDuff.Mode.OVERLAY)
Getting Started
- Add the dependency to your app's
build.gradle
file:
dependencies {
implementation 'com.mikhaellopez:circularimageview:4.3.1'
}
- Add the CircularImageView to your layout XML:
<com.mikhaellopez.circularimageview.CircularImageView
android:layout_width="250dp"
android:layout_height="250dp"
android:src="@drawable/your_image"/>
- Customize the CircularImageView properties in XML or programmatically as needed.
Competitor Comparisons
A circular ImageView for Android
Pros of CircleImageView
- More actively maintained with recent updates
- Supports XML attributes for border width and color
- Includes shadow support out of the box
Cons of CircleImageView
- Slightly larger library size
- Does not support oval shapes, only circular
Code Comparison
CircleImageView:
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="96dp"
android:layout_height="96dp"
android:src="@drawable/profile"
app:civ_border_width="2dp"
app:civ_border_color="#FF000000"/>
CircularImageView:
<com.mikhaellopez.circularimageview.CircularImageView
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"/>
Both libraries offer similar functionality for creating circular image views in Android applications. CircleImageView is more actively maintained and has a simpler API, while CircularImageView provides additional features like shadow support. The choice between the two depends on specific project requirements and desired customization options.
Custom shaped android imageview components
Pros of android-shape-imageview
- Supports multiple shape options (circle, rounded rectangle, etc.)
- Allows for custom shapes through path definitions
- Provides additional features like borders and shadows
Cons of android-shape-imageview
- Less actively maintained (last update in 2015)
- May have compatibility issues with newer Android versions
- More complex implementation due to additional features
Code Comparison
CircularImageView:
<com.mikhaellopez.circularimageview.CircularImageView
android:layout_width="250dp"
android:layout_height="250dp"
app:civ_border_color="#3f51b5"
app:civ_border_width="4dp"
android:src="@drawable/image" />
android-shape-imageview:
<com.github.siyamed.shapeimageview.CircularImageView
android:layout_width="250dp"
android:layout_height="250dp"
app:siBorderWidth="4dp"
app:siBorderColor="#3f51b5"
android:src="@drawable/image" />
Both libraries offer similar basic functionality for creating circular image views. CircularImageView focuses specifically on circular images and provides a simpler, more maintained solution. android-shape-imageview offers more shape options and customization but may require more setup and could have potential compatibility issues due to its age.
Custom view for circular images in Android while maintaining the best draw performance
Pros of CircularImageView (Pkmmte)
- Offers more customization options, including border color and width
- Provides shadow effect functionality
- Includes a selector feature for different states (e.g., pressed, focused)
Cons of CircularImageView (Pkmmte)
- Less actively maintained (last update in 2017)
- May have compatibility issues with newer Android versions
- Larger library size due to additional features
Code Comparison
CircularImageView (lopspower):
<com.mikhaellopez.circularimageview.CircularImageView
android:layout_width="250dp"
android:layout_height="250dp"
app:civ_border_color="#3f51b5"
app:civ_border_width="4dp"
android:src="@drawable/image" />
CircularImageView (Pkmmte):
<com.pkmmte.view.CircularImageView
android:layout_width="250dp"
android:layout_height="250dp"
app:border="true"
app:border_color="#3f51b5"
app:border_width="4dp"
app:shadow="true"
android:src="@drawable/image" />
Both libraries provide similar basic functionality for creating circular image views in Android applications. CircularImageView (Pkmmte) offers more customization options and additional features like shadow effects, but it's less actively maintained. CircularImageView (lopspower) is more lightweight and regularly updated, making it potentially more suitable for modern Android development.
A library for supporting custom shaped ImageView(s) using SVGs and paint shapes
Pros of CustomShapeImageView
- Supports multiple shape options (circle, rounded rectangle, star, etc.) in a single library
- Allows for custom shape definitions using SVG path data
- Provides border and shadow customization options
Cons of CustomShapeImageView
- Less actively maintained (last update was several years ago)
- May have compatibility issues with newer Android versions
- Potentially more complex to implement due to additional features
Code Comparison
CircularImageView:
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="96dp"
android:layout_height="96dp"
android:src="@drawable/profile"
app:civ_border_width="2dp"
app:civ_border_color="#FF000000"/>
CustomShapeImageView:
<com.meg7.widget.CustomShapeImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:src="@drawable/profile"
app:shape="circle"
app:svg_raw_resource="@raw/custom_shape"/>
Both libraries offer simple implementation, but CustomShapeImageView provides more flexibility in shape options at the cost of slightly more complex setup for custom shapes.
A fast ImageView that supports rounded corners, ovals, and circles.
Pros of RoundedImageView
- Supports both circular and rounded rectangle shapes
- Allows for border and shadow customization
- Provides performance optimizations for large images
Cons of RoundedImageView
- Slightly more complex API due to additional features
- May have a larger footprint in terms of code size
- Requires more configuration for simple circular images
Code Comparison
RoundedImageView:
<com.makeramen.roundedimageview.RoundedImageView
android:layout_width="120dp"
android:layout_height="120dp"
app:riv_corner_radius="30dip"
app:riv_border_width="2dip"
app:riv_border_color="#333333"
app:riv_mutate_background="true"
app:riv_tile_mode="repeat"
app:riv_oval="true" />
CircularImageView:
<com.mikhaellopez.circularimageview.CircularImageView
android:layout_width="120dp"
android:layout_height="120dp"
app:civ_border_color="#3f51b5"
app:civ_border_width="2dp"
app:civ_shadow="true"
app:civ_shadow_radius="10" />
Both libraries offer easy-to-use XML attributes for customization. RoundedImageView provides more options for shape and background manipulation, while CircularImageView focuses on circular images with simpler attributes. The choice between the two depends on specific project requirements and desired flexibility.
Give a custom shape to any android view, Material Design 2 ready
Pros of ShapeOfView
- More versatile, allowing for various shape transformations beyond just circular
- Supports custom shapes through path drawing
- Can be applied to any View, not limited to ImageView
Cons of ShapeOfView
- Potentially more complex to use for simple circular shapes
- May have a higher performance overhead due to its flexibility
- Requires more setup code for basic shapes compared to CircularImageView
Code Comparison
CircularImageView:
<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"/>
ShapeOfView:
<com.github.florent37.shapeofview.shapes.CircleView
android:layout_width="150dp"
android:layout_height="150dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/image"/>
</com.github.florent37.shapeofview.shapes.CircleView>
Both libraries offer ways to create circular image views, but ShapeOfView provides more flexibility at the cost of slightly more complex implementation. CircularImageView is more straightforward for simple circular images, while ShapeOfView allows for a wider range of shape transformations on various View types.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
CircularImageView
This is an Android project allowing to realize a circular ImageView in the simplest way possible.
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 |
:information_source: 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.
Top Related Projects
A circular ImageView for Android
Custom shaped android imageview components
Custom view for circular images in Android while maintaining the best draw performance
A library for supporting custom shaped ImageView(s) using SVGs and paint shapes
A fast ImageView that supports rounded corners, ovals, and circles.
Give a custom shape to any android view, Material Design 2 ready
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot