10

現在、すべてのスライドにデフォルトの黒の背景を持つアプリケーションがあります。私がやりたいのは、XML ファイルを変更して背景画像を表示することです。これには簡単なコマンドがあると思いますが、探しているものを正確に見つけることができませんでした。

現在の画面の背景に画像が必要です。背景を変えたくないので、これを XML ファイルに入れたいと思います。これは、私の XML ヘッダーの 1 つの例です...

<?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"
    >

...

次のような簡単なコマンドがあると想定しています

android:background="file"
4

3 に答える 3

18

使うだけandroid:background="@drawable/file_name_without_extension"

ファイルが SD カードにある場合は、xml レイアウトに配置できません。

于 2012-11-26T13:10:36.720 に答える
12

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"
    >

...
于 2012-11-26T13:15:47.883 に答える