New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: cannot avoid center-crop #40
Comments
As a workaround I use this drawable xml file :
|
You can add a viewParent with margin to replace padding this way : <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimenyour_margin"
android:gravity="center">
<com.mikhaellopez.circularimageview.CircularImageView
android:id="@+id/movingIconImageView"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_gravity="center_horizontal"
android:src="@drawable/test"
app:border="true"
app:border_color="#fff"
app:border_width="0px"
app:shadow="true"
app:shadow_color="#000"
app:shadow_radius="8"/>
</LinearLayout> |
@lopspower This won't work. I'm talking about the content within the CircularImageView. The image itself. I don't want it to get cropped. I want it to be centered inside. That's also why I wrote to ignore what's around the CircularImageView in the screenshot. |
Here's a pretty elegant way
where 8dp is the padding |
@sbaar This is the same workaround as I've found, no? Just adding some padding... @lopspower Why close this issue? Is it fixed now ? Or there is some better solution? |
Hello @AndroidDeveloperLB, did you try it in the last version of the library ? implementation 'com.mikhaellopez:circularimageview:3.1.0' |
I can still see it center-cropped. Took my avatar image, changed it to 60x60 px and put into res/drawable folder, and used the same code I've written on the first post (well almost, seems you've added a prefix for each attribute) :
Attached sample project. If I change the scale type to anything (example: center-inside), in the preview it doesn't show as circular anymore, and in runtime it just crashes. |
Yes just see limitation section in the readme:
|
So you see, it's not a nice thing... |
I'll take a look at that. I didn't see the problem that way. I didn't really see the point of using another SacleType for my example but indeed the centerInside can be interesting. I can try to add CenterInside compatibility in a future version. |
Thank you! |
implementation 'com.mikhaellopez:circularimageview:3.2.0' |
How did you do it so fast? |
I think it's still just center-crop . See attached project, which compared the 2 options:
|
I apply the centerInside taking into account the larger side (unlike the centerCrop) to crop the image as little as possible. In your example, your image is square, which is why nothing happens. Also, I don't want to display a second circular image in the middle of the circle. The image displayed in the circularImageView will always be directly related to the size of the view. |
"I apply the centerInside taking into account the larger side (unlike the centerCrop) to crop the image as little as possible." " In your example, your image is square, which is why nothing happens." "Also, I don't want to display a second circular image in the middle of the circle. The image displayed in the circularImageView will always be directly related to the size of the view." Look at the support library FAB. When you give it an image (especially a square one) , it just puts it in the center, without cropping of any kind.. |
Is this issue fixed? I noticed CenterInside still works as same as CenterCrop |
@chrismabotuwana As I wrote, it's not fixed. |
suppose I have a small image to show inside the circularImageView, how do I avoid it being center-cropped?
I've set this:
and the image is of size 58x60 dp (it's in the mdpi folder and has the same pixels size as the dp).
Yet this is what I see (ignore what's behind ) :
Same thing occurs when I have a 100x100 dp of the view. It always does center-crop...
I've tried changing the scaleType, but it doesn't do anything.
I've even tried forcing padding, but it didn't help.
The text was updated successfully, but these errors were encountered: