background是指背景,src是指内容。
之所以有这两个,是考虑到src如果是PNG格式等有透明属性的图片的话,就会在透明的地方显示出设置的background的背景,而不是黑色或者其他系统默认的填充色等。这样也是有助于美观的。
background 就是背景没错呀 src 指的是 ImageView 要显示的图像
<ImageView
android:id="@+id/dummy_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#0F0"
android:contentDescription="@string/hello_world"
android:scaleType="fitStart"
android:src="@drawable/ic_launcher" />
背景就是在后面的东西,不会前来干扰你前面的 src
当然,同 frank 所述,当 src 有透明效果时,可将背景色显示在 src 中,比如下面的回形针就是透明的,用的是背景的绿色