How to set background image in android XML
Here I am sharing how you can set a background image in an android application with XML.
There are two ways you can add images first is “android:src” attribute and second is android:background“. If you want to use build in images you can refer them as “@android:” and if you wan to use your own custom image(that is what we use most of the time), you can refer them as “drawable/image_name”.
For the custom image add/copy add it to the drawable folder and update XML file like below:
And bow add
Worth to mention here that, you don’t need to mention the extension of that file, Android will take it automatically. Which means you can not have two files with the same name in image folder even though they are with different extensions. And also be sure you do not have upper case and number in image name which will generate an error while building Android application.
For built in images do like below:
Hope it will help some out there….