Posted on Leave a comment

Android ImageView not displaying image in few phones only

Issue:

Android ImageView was not displaying image on Redmi Note Prime, when tested. But the same code when used in Redmi 4A shows image. 

Image which was being used

Solutions tried:

  1. Setting Image using XML
    Used: 
    android:src
  2. Setting image using Java code
    Used: 
    ImageView img;
    img = (ImageView) findViewById(R.id.startscreen);
    img.setImageResource(R.drawable.startimage);
  3. Setting background to different colour
    Used:
    android:background
  4. Changing the background colour of image
  5. Using AppCompat
    Used: 
    app:srcCompat

Solution that worked:

After googling all possible methods, we came across a comment where ‘Resizing the image’ was an option.

Initially, our image had a resolution of 1587 x 2245. We reduced the pixels by half (50%). And then tried without changing the code. Changing the image resolution did the trick for us !

In case you are stuck with image being displayed on a device and not on another, either use multi-resolution content, or use content that fits into all.