Warm tip: This article is reproduced from stackoverflow.com, please click
android apk image png xml

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

发布于 2021-02-25 07:25:43

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

Questioner
xxyninaxxy
Viewed
0
2,770 2020-11-02 23:24

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>