Difference between a View's Padding and Margin

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

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

14条回答
  •  野性不改
    2020-11-22 07:11

    To help me remember the meaning of padding, I think of a big coat with lots of thick cotton padding. I'm inside my coat, but me and my padded coat are together. We're a unit.

    But to remember margin, I think of, "Hey, give me some margin!" It's the empty space between me and you. Don't come inside my comfort zone -- my margin.

    To make it more clear, here is a picture of padding and margin in a TextView:

    xml layout for the image above

    
    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
    
    

    Related

    • Gravity vs layout_gravity
    • Match_parent vs wrap_content

提交回复
热议问题