ImageButton not displaying drawable correctly – Android 4.4.2
By: Kevin | March 29, 2014
While working on a project running 4.4.2 I ran into a strange behavior from ImageButtons. I was using standard images from the Android Icon Pack and found that, what appeared random, some images would not display with the correct colors when running on my Moto X. I was developing on my Mac using IntelliJ’s Community Edition 13.0.3 and the images would render with the correct colors from the IDE however when ran on my device I got this.
I found this really strange. I double and tripple checked that I had put the correct images in the drawable folders. I cleaned the IDE, restarted, deleted the images and re-inserted, nothing worked. Giving up for the weekend I came back to the issue and found what is a very simple fix. I noticed that all images in the Android Icon Pack have the naming convention “ic_some_action.png”. I changed the names of all my images to single words, all lowercase, with no underscores (“_”). So, “ic_new_image.png” became “newimage.png” and “ic_camera.png” turned into just “camera.png”. For some reason this did the trick, the next time I ran on my device I got this.
I still don’t know why this happens however I now rename all my images to single words before putting them in there respective drawable folders.