参考
http://blog.youkuaiyun.com/dalancon/article/details/42495287
场景
imageView1.setImageResource(R.drawable.img);
imageView2.setBackgroundResource(R.drawable.img)
imageView1和imageView2是两个相同的ImageView。他们都是在同一个RelativeLayout父容器里面,RelativeLayout的android:background=”@color/transparent”,也就是父容器背景透明。
效果
imageView1
imageView2
总结
setImageResource是设置图片但不改变背景色。
而setBackgroundResource是改变背景色。