Search code examples
androidxmlimageapkpng

How do I add a background image to an XML file?


How do I insert a background image in an xml file? I would like to add a background image to my APK (for mobile phone), I have already found the xml file, but I don't know where to insert the ID of the image and also not whether android: background or android: icon Can someone help me? The XML is in the picture and btw sorry for the picture i dont know how to copy a xml code in the questionenter image description here


Solution

  • It's done with android:background="", like this:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/your_image_id"> 
    </LinearLayout>