Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image not appearing on HTC One M8

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.

like image 621
Mathijs Segers Avatar asked Mar 15 '23 19:03

Mathijs Segers


2 Answers

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.

like image 187
Breavyn Avatar answered Mar 23 '23 16:03

Breavyn


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,

  1. Use android:largeHeap="true" on the element in the activity manifest. This will give your application a large heap size.

  2. Use a Image Loading library like Android-Universal-Image-Loader

  3. Use an optimized image with less resolution.

like image 33
Prokash Sarkar Avatar answered Mar 23 '23 15:03

Prokash Sarkar