hdodenhof / circleimageview Goto Github PK
View Code? Open in Web Editor NEWA circular ImageView for Android
License: Apache License 2.0
A circular ImageView for Android
License: Apache License 2.0
I have used your class in my app.Actually i wanted to set background to whole circle imageview but it is not working,when i am setting background color it is setting in square shape,but i need in circle imageview only
Will it be possible to add shadows to the CircleImageView? Or is it already possible and I just don't know why? :-)
I found a Solutions https://github.com/lopspower/CircularImageView.
but It is Not Working on less than API 11.
Q: How can I use it in my project contain API level 7?
I get the following error when trying to build:
FAILURE: Build failed with an exception.
Where:
Script 'https://raw.github.com/hdodenhof/gradle-mvn-push/master/gradle-mvn-push.gradle' line: 60
What went wrong:
A problem occurred configuring project ':libraries:circleimageview'.
No such property: POM_DESCRIPTION for class: org.gradle.api.publication.maven.internal.CustomModelBuilder
Any toughts?
I am trying to set a custom animation when a drawable is set on the CircleImageView, but the view doesn't seem to be refreshed whenever it has finished loading. I am using the view on each of my adapter's rows. The view seems to be stuck with the default drawable it has before I request the Universal Image Loader to load, and it is only updated whenever I cause the row to be recycled (scroll it away and then back in)
here is the code of the displayer:
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public void display(Bitmap bitmap, ImageAware imageAware, LoadedFrom loadedFrom) {
if ((loadedFrom == LoadedFrom.NETWORK) || (loadedFrom == LoadedFrom.DISC_CACHE)) {
ImageView imageView = (ImageView) imageAware.getWrappedView();
Drawable previous = imageView.getDrawable();
final TransitionDrawable td =
new TransitionDrawable(new Drawable[]{
(previous == null ? transparent : previous),
new BitmapDrawable(mResources, bitmap)
});
td.setCrossFadeEnabled(true);
imageAware.setImageDrawable(td);
td.startTransition(FADE_IN_TIME);
} else {
imageAware.setImageBitmap(bitmap);
}
}
Are there any workarounds for this?
I'm trying to get a Bitmap from CircleImageView using getDrawingCache and always get null. I do this...
CircleImageView civProfilePic = new CircleImageView(this);
civProfilePic.setBorderWidth(5);
civProfilePic.setImageBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.user2));
Bitmap roundImage = civProfilePic.getDrawingCache();
and roundImage == null
I use CircleImageView in Toolbar, but the height is not suit for toolbar height.
Hi! Thanks a lot for this great View!
Is it possible to setup padding of the image to make it look smaller inside the circle?
android:padding - works OK for default ImageView, but not for CircleImageView.
I see the border_width attribute, but it makes image to be cut in circle and resize, not just scale it as-is.
I had the same problem that #5 with RoboSpice library and his SpiceArrayAdapter which use a fade animation.
This SpiceArrayAdapter doesn't provide function to disable this feature, and we can't extends to override some function because the relevant code is in private inner class.
So the basic "solution" that i fund is to extends from CircleImageView for :
@Override
public void setImageDrawable(Drawable drawable){
if(drawable instanceof TransitionDrawable){
TransitionDrawable transitionDrawable=(TransitionDrawable) drawable;
super.setImageDrawable(transitionDrawable.getDrawable(1)); //love magic numbers !
}
else super.setImageDrawable(drawable);
}
So we may be we shoud add this in the Limitations section of README ?
In order to support Transition animation you have to implement a RoundedDrawable and round all the layers of LayerDrawable inside TransitionDrawable
I've implemented this in my project, so I can contribute
This is very memory efficient
this is awesome....:-)
but i got some exception over 2.3.5 and lesser versions that is
java.lang.NoSuchMethodException: setLayerType
In the last couple of hours I'm been trying to use CircleImageView with Android Studio. It worked great with Eclipse, however with Android Studio I'm getting the following error:
Error:No such property: GROUP for class: org.gradle.api.publication.maven.internal.ant.DefaultGroovyMavenDeployer
If I comment the line "apply from: 'https://raw.github.com/hdodenhof/gradle-mvn-push/master/gradle-mvn-push.gradle'" I won't get any error however when I open the xml file I get:
The following classes could not be found: de.hdodenhof.circleimageview.CircleImageView
How can I solve this?
Thanks in advance!
please create app:shadow="2dp"
circleImageView.setColorFilter(Color.parseColor("#77000000"));
It cant work;
Hi,
I'm facing a quite interesting problem on Android Lollipop - if I set Bitmap to CircleImageView with setImageBitmap() method, it just shows black image:
Image is selected from Gallery app, and I can view it in debug mode (bitmap is not corrupted).
Everything is working OK with default ImageView:
This behaviour is random - some images are working correctly, some are not, and it occurs only on Android Lollipop.
Do you have any suggestions? I've checked app logs, everything is working OK - no OutOfMemory exceptions or something similar.
when I use CicleImageView in my maven project by dependencing Maven Repository,my projectc can`t find CircleImageView。But I find that your maven repository (version 1.2.1) has a values.xml file in res/values directory instand of a attrs.xml file in res/values directory which is in your github project。when I use attrs.xml replace values.xml,my maven project run success。Please insure your values.xml file in your maven repository 。
If you add a background color, the view turns into a square instead of a circle. How do you fix this?
when the CircleImageView use on android 5.0 , Have a gray square, can be seen when click disappeared, what reason is this?
I use your library (btw: great work!) for user profile images in my app. User images come via Facebook and are loaded using Picasso.
However, when I open a fragment / activity that contains a CircleImageView, it gets first filled with my placeholder image. "Behind the scenes", Picasso starts loading the image and finally puts it in my CircleImageView object. But it's nit displayed immediately and I still see the placeholder! I have to perform somehow a "view reloading" action, like scrolling down in a ListView and then scroll up again back to the CircleImageView. Only at this point the real picture gets displayed instead of the placeholder image.
It seems like the CircleImageView does not redraw its content if Picasso puts the loaded content in there. In your README you stated that the library can be used with Picasso .. did you have the same problems? Are any workarounds known?
Dependency
compile 'de.hdodenhof:circleimageview:1.3.0'
Getting error when building:
Error:(2) Attribute "border_color" has already been defined
Error:(2) Attribute "border_width" has already been defined
I don't have these values in my values/colors.xml or anywhere else.
This problem occured when adding this library to my gradle file.
1px border is drawn even when border width is set to ;
Cause:
public void setStrokeWidth (float width)
Added in API level 1
Set the width for stroking. Pass 0 to stroke in hairline mode. Hairlines always draws a single pixel independent of the canva's matrix.
I'm using Picasso to load images into your image view and the fade is causing problems for it. Because you are getting the bitmap from the drawable it's only getting the drawable in a static state. It will only show the placeholder if the image hasn't loaded yet, it will show a cross faded image if the image is being faded, or it could show the actual image if the load is quick enough to be done before it gets the Bitmap.
You can work around this by disabling the fade, but it would be great if this wasn't necessary.
It can not show image on Google Nexus device
If you set the background color of the CircleImageView, it will fill the entire rect of the view, extending outside the circular border.
Currently this library has targetSdkVersion 19
.
This enforces all projects using gradle to have targetSdkVersion >= 19 when depending on this library.
If this library doesn't rely on newer SDK, it might be better to reduce the targetSdkVersion.
https://groups.google.com/forum/#!topic/adt-dev/KaY5m5PY0N4
Thanks!
Is it support the downloaded image from network using Universal Image Loader ? I am getting error when try to set image downloaded from network using UIL .
On using CircleImageView as a child of cardview, whatever the layout_height
of the cardview may be, it takes the height of CircleImageView.
To put it in a different way - the cardview's height somehow becomes wrap content, and becomes just large enough to fit the CircleImageCiew.
In my use case, the circle should sometimes display an image (which I load through Glide) and sometimes should have a solid color (which I set .setImageDrawable(new clorDrawable(Color.parseColor(....))).
The latter works fine in < Android 5.0, but only displays a gray color in Android 5.0
Any ideas?
Till now I used to use Picasso for loading images. Right now I'm moving to Glide and there's an issue with that.
When loading images from the internet for the first time, it doesn't show up in the CircleImageView (Glide isn't able to replace the placeholder image).
I have an activity with just a CircleImageView. I use the below code to load image using glide
Glide.with(this)
.load("https://s3.amazonaws.com/xyz.png")
.placeholder(R.drawable.abc)
.into(imgView);
Note: I have tried replacing the CircleImageView with a regular ImageView and it works perfectly.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="1">
<ImageView
android:layout_width="match_parent"
android:layout_height="96dp"
android:src="@drawable/ic_launcher"
android:layout_gravity="center"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical">
<suntek.com.expensemanager.ImageView.CircleImageView
android:layout_width="match_parent"
android:layout_height="96dp"
android:src="@drawable/ic_launcher"
android:layout_gravity="center"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical">
<suntek.com.expensemanager.ImageView.CircleImageView
android:layout_width="match_parent"
android:layout_height="96dp"
android:src="@drawable/ic_launcher"
android:layout_gravity="center"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
I use ColorDrawables as placeholders while profile pictures are being loaded from the network. However, ColorDrawables have an intrinsic height and width of -1, causing Bitmap.createBitmap to fail in CircleImageView.getBitmapFromDrawable.
Hi man,
thanks for sharing your work with us.
Working with your library I discover a problem with drawable and color filter.
If i write something like:
Drawable drawable = getResources().getDrawable(R.drawable.generic_image); drawable.setColorFilter(COLOR.RED, PorterDuff.Mode.SRC_IN); circleImageView.setImageDrawable(drawable);
The drawable will be load correctly but without the color filter.
Using the same code with a normal ImageView the drawable will be rendered correctly.
This problem can be generated with every image (advice: use a gray image the color filter will be more effective).
I'm here if you need more info.
Thanks again.
Are there any issues setting minSdkVersion to 8? Or even a lower value?
At least building with min API 8 works.
have conflict with picasso .when i load drawable twice.
because the method "setImageDrawable()" cause invalidate twice.
I resolve by:
@OverRide
public void setImageDrawable(Drawable drawable) {
mBitmap = getBitmapFromDrawable(drawable);
setup();
super.setImageDrawable(drawable);
}
can i set the background color to circle area?
And why not a zoom effect as here : https://github.com/balysv/material-ripple.
but with the one above the ripple will be disapear when it touch the square layout
are you planning to support other scaleTypes apart from default which you support?
If Not >>> can you guide or add pointers to do the same.
Hello,
I am trying to display circle image on profile screen as soon as onActivityResult call is reached, it initially disappears the current view i.e White color of imageview and then it loads. Why it doesn't stay to white until it gets loaded?
<com.kickzexchange.custom.CircleImageView android:id="@+id/ivProfileImage" android:layout_width="100dp" android:layout_height="100dp" android:layout_marginTop="10dp" android:src="@color/White" app:border_color="@color/Maroon" app:border_width="2dp">
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == SELECT_IMAGE_RQ_CODE) {
if (resultCode == Activity.RESULT_OK) {
ivProfileImage.setImageResource(mActivity.getResources()
.getColor(R.color.White));
ivProfileImage.setBorderWidth(2);
ivProfileImage.setBorderColor(getResources().getColor(
R.color.Maroon));
Uri selectedImageUri = data.getData();
Picasso.with(this).load(selectedImageUri)
.into(ivProfileImage);
}
}
}
I am having issues when i set the background of the circular image view. The resource specified in the background dows not draw to circle.
Basically, I am having a trapsparent background image, If I do not set the background, the view in the back of circular image view gets displated in the remaining space. But when i try to set the background resource (Basically a color), it is being drawn to full layout (REMAINING SPACE OUTSIDE THE CIRCLE {AS CircleImageView is basically a rectangular canvas, with a circular image on top of it.})
I scale down the images and set it to the CircularImageView. Certain images are rotated to the left when its set. This seems to be random as it works fine for certain images.
hi i want to set size for all images
for example i have four images 200_100 and 150_150 and 300*200 and 1500 *1000
i want to set size for all image 200*300
what should i do ?
thanks alot
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.