在Android中,可以使用ImageView控件来设置背景图片。可以使用以下两种方式进行设置:
1. 在布局文件中设置背景图片:
```
android:layout_width="match_parent" android:layout_height="match_parent" android:src="@drawable/background_image" /> ``` 其中,`@drawable/background_image`是指定背景图片的资源文件。 2. 通过代码设置背景图片: ``` ImageView imageView = findViewById(R.id.imageView); imageView.setBackgroundResource(R.drawable.background_image); ``` 其中,`R.drawable.background_image`是指定背景图片的资源ID。 需要注意的是,ImageView控件在设置背景图片时,会根据控件的宽高自动缩放图片大小以适应控件。如果需要保持背景图片的原始尺寸,可以使用`android:scaleType`属性来设置缩放类型。例如: ``` android:layout_width="match_parent" android:layout_height="match_parent" android:src="@drawable/background_image" android:scaleType="centerCrop" /> ``` 其中,`android:scaleType="centerCrop"`表示缩放类型为居中裁剪。可以根据实际需求选择不同的缩放类型。