Difference between a View's Padding and Margin

后端 未结 14 2894
渐次进展
渐次进展 2020-11-22 06:45

What is the difference between a View\'s Margin and Padding?

14条回答
  •  不思量自难忘°
    2020-11-22 06:49

    In addition to all the correct answers above, one other difference is that padding increases the clickable area of a view, whereas margins do not. This is useful if you have a smallish clickable image but want to make the click handler forgiving.

    For eg, see this image of my layout with an ImageView (the Android icon) where I set the paddingBotton to be 100dp (the image is the stock launcher mipmap ic_launcher). With the attached click handler I was able to click way outside and below the image and still register a click.

提交回复
热议问题