`
modabobo
  • 浏览: 516317 次
文章分类
社区版块
存档分类
最新评论

ImageView的background属性与src属性的区别

 
阅读更多

ackground 就是背景, src 指的是 ImageView 要显示的图像

  1. <ImageView
  2. android:id="@+id/dummy_left"
  3. android:layout_width="wrap_content"
  4. android:layout_height="wrap_content"
  5. android:background="#0F0"
  6. android:contentDescription="@string/hello_world"
  7. android:scaleType="fitStart"
  8. android:src="@drawable/ic_launcher" />

背景就是在后面的东西,不会前来干扰你前面的 src。

之所以有这两个,是考虑到src如果是PNG格式等有透明属性的图片的话,就会在透明的地方显示出设置的background的背景,而不是黑色或者其他系统默认的填充色等。这样也是有助于美观的

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics