question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: cannot avoid center-crop

See original GitHub issue

suppose I have a small image to show inside the circularImageView, how do I avoid it being center-cropped? I’ve set this:

            <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"/>

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 ) :

untitled20151216104018

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.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:18 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
AndroidDeveloperLBcommented, Jul 17, 2018

How did you do it so fast?

1reaction
sbaarcommented, Jul 17, 2018

Here’s a pretty elegant way

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true">
        <inset android:inset="8dp" android:drawable="@drawable/ic_check_white"/>
    </item>
    <item>
        <inset android:inset="8dp" android:drawable="@drawable/lock_v2"/>
    </item>
</selector>

where 8dp is the padding

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android studio XML centercrop doesn't center the image
I have added a background-image in Android Studio, I used center-crop to center it. The problem I have is that the image does...
Read more >
Displaying Images with the Picasso Library
Note: there is a bug with the current version of Picasso that prevents large images ... Transform options include centerCrop() (Crops an image...
Read more >
How to set a "CenterCrop" & "Round Corner" bitmap into a ...
Now the problem presents : The "CenterCrop" & "Rounded Corner" bitmap cannot be loaded at the "First Time"(which means the picture I have...
Read more >
Allow Notification BigPicture to use all kind of image scale ...
Default scaling behavior of Notification BigPicture style is to center-crop any kind of image provided, making too dificult to adapt and use it...
Read more >
center crop image based on other image dimension
The mapping toolbox stuff is not a problem, I only need help with cropping the same part from both images (RGB AND TIR)....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found