Skip to content
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

Image unwanted black background #31

Closed
DenisMondon opened this issue Oct 29, 2015 · 12 comments
Closed

Image unwanted black background #31

DenisMondon opened this issue Oct 29, 2015 · 12 comments
Assignees
Labels

Comments

@DenisMondon
Copy link

Hi!

I have a black background when using your walter image. But when using a transparent image (ic_launcher), it works perfectly... I can't find the solution. Can you help me?

Here is the screenshot:
device-2015-10-29-125401
And here is the xml code:

            <com.mikhaellopez.circularimageview.CircularImageView
                android:layout_width="96dp"
                android:layout_height="96dp"
                android:scaleType="centerCrop"
                android:src="@drawable/walter"
                app:border="true"
                app:border_color="@android:color/white"
                app:border_width="3dp"
                app:shadow="true"
                app:shadow_color="#000000"
                app:shadow_radius="6"/>

            <com.mikhaellopez.circularimageview.CircularImageView
                android:layout_width="96dp"
                android:layout_height="96dp"
                android:scaleType="centerCrop"
                android:src="@drawable/ic_launcher"
                app:border="true"
                app:border_color="@android:color/white"
                app:border_width="3dp"
                app:shadow="true"
                app:shadow_color="#000000"
                app:shadow_radius="6"/>
@lopspower
Copy link
Owner

The problem came from the property android:scaleType="centerCrop".
Indeed, you don't need to use it, since this property is automatically manage in the library.
But thank you for your return, I'll still try to correct this point if someone uses it again.

@DenisMondon
Copy link
Author

Oh thank you! I didn't think about that!
Have a good day! Thanks a lot.
Denis

@mohammadrafigh
Copy link

I have the same issue exactly with your sample code in readme.md and without scaleType

@lopspower
Copy link
Owner

Please download the sample project "circularimageview-example" and try to see the difference with your implementation.

@m1ga
Copy link

m1ga commented Feb 23, 2016

Same here. Gif is working fine, a jpg has a black background

@lopspower lopspower reopened this Feb 25, 2016
@lopspower lopspower added the bug label Feb 25, 2016
@lopspower lopspower self-assigned this Feb 25, 2016
@m1ga
Copy link

m1ga commented Feb 25, 2016

Tried https://github.com/vinc3m1/RoundedImageView and it worked with the same JPG file and no black background. But it doesn't feature the nice dropshadow, so your module would be a better alternative :)

@lopspower
Copy link
Owner

I actually identified the problem.
I posted a question on stackoverflow if you want to try to contribute.

@lopspower
Copy link
Owner

@m1ga Do you know if with RoundedImageView your view is centered when you integrate your view in the view parent with android:gravity="center" this way:

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:orientation="vertical">

        <CustomView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

</LinearLayout>

@m1ga
Copy link

m1ga commented Feb 25, 2016

yes it's

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:background="#ffffff"
    android:orientation="vertical">

@lopspower
Copy link
Owner

I had new release to fix that temporarily but you must specify the size of the view if you added to a parent view using a gravity:

compile 'com.mikhaellopez:circularimageview:3.0.2'

@priegler
Copy link

I still have the same issue as described (I am on v3.0.2). Any updates on that one? In my case I defined the size of the view as you suggested @lopspower

@priegler
Copy link

I played arround for some time now and found out that the black background disappears when I use app:civ_shadow="false".
So what I do now as a workaround is to activate the shadow in code circularImageView.addShadow();
Then everything works unless I also add setShadowColor (which again causes the black background).

Maybe this helps to fix the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants