-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Problems with Lollipop - black image #31
Comments
Hi @zplesac! Any specific format, dimensions or other things that seem more prone to
|
Hi @karllindmark, I've investigated further, and it seems that problem is occurring only on high-res pictures (i.e. 2448 x 3264 - highest resolution on Nexus 4). If I downgrade camera resolution and quality, everything is working OK. |
Interesting! I'll try to reproduce the issue and look into it. |
I also have almost the same problem. Works perfect on Android version lower than Lollipop. Thanks. |
I have still no idea why that happens, but I agree that it seems to be connected to the high resolution. I'll stay on it. As a quick workaround you could just scale down the |
Agreed, that could be quick & dirty solution. |
anyone found a proper solution for this problem? |
I haven't look into this any more. But I again strongly suggest to only load a scaled-to-fit |
The scaled down version doesn't look so good on nexus 6. I tried that. But its workable so I guess I'll just stick with that. |
@15100103 What's are the dimensions of your image and the |
i have the same problem, on android 5.0 |
Oh, yes I find the The solution, you can open the 'hardwareAccelerated' on android 5.0. |
The Solution is here my friends: I have same problem : and I Find solution. Solution: Like image_profile.setImageURI(Uri.fromFile(new File("Your image local file path"))); |
I still have the same problem, I am using Picasso to load every pictures. The dimension of my picture is 300x300. I have CircleImageView and Picasso update to the lastest version. P.S : Used in an RecyclerView Adapter. |
public class CircleImageView extends ImageView {
} |
Same problem, does anyone know how to fix?? |
I have same problem with
on HTC One, Android 5.0.2: I set the image by:
or in the layout file:
The xhdpi file photo.png is 17 Kbyte and 240x240: |
I think I found a solution in lollipop. myView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); This disable hardware acceleration. You can use this to circleimageview's parent view, profile_img_container. Don't use this to circleimageview directly. It willl show you black outer circle. <LinearLayout
android:id="@+id/profile_img_container"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:paddingTop="20dp"
android:paddingBottom="20dp"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax">
<de.hdodenhof.circleimageview.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/profile_image"
android:layout_width="96dp"
android:layout_height="96dp"
android:src="@drawable/profile002"
android:layout_marginTop="20dp"
app:civ_border_width="1dp"
app:civ_border_color="#44000000"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax"/>
</LinearLayout> |
@soulawaker |
I'm happy to hear that. Good luck to you, Anton. :)
|
myView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); awesome solutions , this is working in my lollipop code , Thanks a lot |
Solution: Wrap the CircleImageView with a layout LinearLayout or FrameLayout, set the LAYER TYPE propperty to software. That's all. |
Use setLayerType (int layerType, Paint paint) |
谢谢! |
Hi All, |
android:layerType="software" works perfectly |
Could you guys stop replying about Because that would be just a workaround, which costs your app performance. |
@afarber is right, using software rendering is just a workaround which can have significant performance implications. After some research it seems there are some bitmap decoding issues on a couples devices, e.g. Moto X. To pin this down please provide the following if you are still having this issue:
|
I had this on Moto G generation 2, but don't have that device right now. |
Hi all, |
@suresh1295 I also set the background on my image view and that made it work. |
android:layerType="software" |
set container layerType = "hardware", and |
Can someone open a PR with this fix? So that we can get it included in next release? |
Using |
One thing I noticed is that, this situation only occur when we try to load images from resources. I'm developing a music player and extracted all the artwork in one place. It works fine with that extracted artwork but when I put the same images in the drawable folder it fails to load. |
In Android5: it works for: myView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); |
but that's not a proper solution to this because this will display a very low resolution image. |
I had this issue come up due to the use of In Android Studio at least, I turned off shrinkResources, uninstalled the app, and did Build->Clean Project, then re-built/re-installed/re-ran and the images returned. However, I did try the following which allowed the images to stay viewable when using
For further reading: https://developer.android.com/studio/build/shrink-code.html |
Perhaps i have found why this happened ,if you have this problem, check your codes ,and make sure the bitmap that you are using has not been recycled. |
@whimaggot it wasn't, only setting container of image view to software rendering worked for me |
@Zhuinden how you were loading the image? Glide or something else? |
Glide of course |
did you use .dontAnimate() on glide while loading image? I too faced this issue, but somehow it got fixed. I don't exactly remember the solution correctly. Using software rendering will result in the low-quality image. |
@Zhuinden Use glide with circle transformation instead of this library; and if the same problem exists there, please report the affected device to bumptech/glide#738 Edit: it's just
|
Layer type software on the container works for me, I've been using that with success I don't have the capacity to test the alternative at this time but thanks |
wow!! image_container.setLayerType(View.LAYER_TYPE_SOFTWARE, null); works fine even for Kitkat |
use glide with drawables and custom transformations.This worked perfectly for me. |
The workaround here works, but only the first time. If I move away from the screen and go back, then it has a black bg again. How is this still an issue 3 years later?! |
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.
The text was updated successfully, but these errors were encountered: