Difference between src and background for image view [duplicate]

醉酒当歌 提交于 2019-12-02 12:57:59

But both are looking differnt

First, the drawables are different.

Second, the background always scales to the size of the view.

when i press the imageview with background set it is not showing the selection. can anyone explain why this happens

The selection effect is because by default, the background is a StateListDrawable with a different appearance in state_pressed. Your custom background looks the same in all states. You can create StateListDrawables in xml with a selector.

Background will fill all avaliable place of view, src - will paste image and scale/positioning using ImageView parameters. For example, parameters "scaleType", "scaleX", "scaleY", "gravity", "adjustViewBounds" will affects only on src image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!