我如何将imageview设置为背景?

时间:2016-12-20 21:41:57

标签: android background imageview

我是android studio的新手,并且不知道如何将Imageview设置为背景。

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1"
>

<ImageView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:srcCompat="@android:drawable/arrow_up_float"
    android:id="@+id/imageViewFull" />

1 个答案:

答案 0 :(得分:1)

您无需添加图像视图即可将图像设置为背景。你可以通过添加来实现         android:background="@drawable/background_image"  到布局标签。

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
               xmlns:app="http://schemas.android.com/apk/res-auto"
               android:orientation="vertical"           
               android:layout_width="match_parent"
               android:layout_height="match_parent"
               android:weightSum="1"
       android:background="@drawable/background_image">

有关替代方法,请参阅此问题 Full screen background image in an activity