Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/186.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何在布局背景中插入图像?_Android - Fatal编程技术网

Android 如何在布局背景中插入图像?

Android 如何在布局背景中插入图像?,android,Android,在android的登录布局背景中插入图像。如下- <?xml version="1.0" encoding="utf-8"?> <RelativeLayout android:id="@+id/loginLayout" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_

在android的登录布局背景中插入图像。

如下-

  <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout android:id="@+id/loginLayout" xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" android:background="@drawable/background">
    ....
    ....
    </RelativeLayout>

....
....
xml格式:

android:background="@drawable/your_image"
代码内(
setBackgroundDrawable
自API 16以来已被弃用,但仍然有用)

自API 16起:

.setBackground(Drawable d)


只需将此
android:background=“drawable/yourimage”
设置到您的
login.xml的父布局中
android:background=“@drawable/yourback”为什么这不是真正的问题?它很短但很清楚。android:orientation=“vertical”它对RelativeLay有用吗???@PadmaKumar足够了吗?请参见编辑。
.setBackground(Drawable d)
<?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:background="@drawable/ad_screenfull"
    android:orientation="vertical" >
</LinearLayout>