-1

I have a couple of phones I am testing my app on. On some of them, I am able to set the background resource using the following code:

mLinearLayout.setBackgroundResource(R.drawable.blurred_shanghai_startpage);

However on others the background is simple white, the rest of the app/pictures function normally however. There does not seem to be any correlation between phone model or Android version with whether or not the background is the picture I set it to, or just a blank white screen. I have also tried looking through the Android Log for anything referencing "unable to set background image" but I am unable to find anything. I have also tried directly setting the background from the XML, however this has the same effect as setting it in Java, it works on some phones, but not on others.

If anyone has ever had this issue before I would greatly appreciate some help.

ethanzh
  • 133
  • 2
  • 5
  • 19
  • Put the image on your SD card and see if you can open it via a file manager or your browser. I've recently discovered a problem with Android devices opening certain types of images which have had the EXIF data "messed with". – eoinzy Apr 26 '16 at 14:18
  • I just tried this. I am able to open it in the default Xiaomi file browser – ethanzh Apr 26 '16 at 14:22

2 Answers2

0

you can do like this

layout.setBackgroundDrawable( getResources().getDrawable(R.drawable.ready) );
Farmer
  • 4,093
  • 3
  • 23
  • 47
0

in your xml code, check mLinearLayout has an attribute src instead of background. Then set background resource as u are doing.

mLinearLayout.setBackgroundResource(getResources().getDrawable(R.drawable.blurred_shanghai_startpage));

vibhor_shri
  • 374
  • 2
  • 12