XML文件中的Android背景图片

Jui*_*iCe 10 xml android background

我目前有一个应用程序,每张幻灯片都有默认的黑色背景.我想要做的是改变XML文件以获得背景图像.我假设有一个简单的命令,但无法找到我正在寻找的确切内容.

我想要一个图像到我当前屏幕的背景.我不希望背景发生变化,我想把它放在我的XML文件中.以下是我的一个XML标头的示例...

<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="1.0" >
<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
   android:weightSum="9"
   android:gravity="center"
    >

...
Run Code Online (Sandbox Code Playgroud)

我假设有一些简单的命令,如

android:background="file"
Run Code Online (Sandbox Code Playgroud)

jau*_*ard 16

只是用 android:background="@drawable/file_name_without_extension"

如果您的文件在SD卡上,则无法将其放在xml布局上.


Kan*_*mal 11

android:background ="@ drawable/imagename"

<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:background = "@drawable/imagename"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="1.0" >
<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
   android:weightSum="9"
   android:gravity="center"
    >

...
Run Code Online (Sandbox Code Playgroud)


小智 5

你可以试试 android:background = "@drawable/imagename"

我希望你的drawable文件夹中有一个图像