What is the difference between src and background of ImageView

前端 未结 4 1719
[愿得一人]
[愿得一人] 2020-11-28 06:03

I am a puzzled about using src or background for an ImageView.

I know the former means the content of this ImageView

4条回答
  •  -上瘾入骨i
    2020-11-28 06:12

    The difference between XML attribute src and background in ImageView:

    The background will stretch according to the length given by the ImageView component, and SRC will hold the size of the original image without stretching. SRC is the picture content (foreground), BG is the background, can be used at the same time.

    In addition: ScaleType only works on SRC; BG can set transparency, for example, in ImageButton, you can use Android:scaletype to control how the image is scaled, sample code as follows:

     
    

    Feel free to ask doubt if you get any.

提交回复
热议问题