I'm currently developing a new app for the company I'm working at. We test this on multiple devices, now a strange thing I noticed the other day, well someone else did.
My Colleague tested the app on his HTC one m8, and we have a background image on the login page but it didn't show for him. It did however on a Nexus 7, Samsung Galaxy Tab 4, Motorola G and Samsung S4.
This might be very specific, but I guess some people must have noticed this kind of behaviour before on certain devices and found out why this could possibly occur?
The image is saved in the regular drawable folder and has a size of 1400px933px and it's a jpeg.
I wonder if anyone has any clue.
The ImageView is the first child of a relative layout, with a size of match parent in both width and Height. So it should just fit, other views are on top of this one.
I believe this problem is also to do with how android scales the images. Try putting the image into a drawable-nodpi
resource folder.
The drawable
folder is the same as drawable-mdpi
. On the HTC One M8 images qualified as mdpi
are scaled up by a factor of 3. So your 1400x933px
image becomes 4200x2799px
. The maximum size allowed by OpenGL is 4096x4096
.
I faced a similar issue with Samsung Galaxy Note 3. This was the only device that failed to load a large bitmap image. After a quite long search I finally found that some phone uses a small heap size for applications by default. This is because of the memory optimization and preventing memory leak issue. So basically you can do the following things to solve this,
Use android:largeHeap="true"
on the element in the activity manifest. This will give your application a large heap size.
Use a Image Loading library like Android-Universal-Image-Loader
Use an optimized image with less resolution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With