android:padding和android:layout_margin的区别

padding是描述本view里面的内容到本view的上下左右边的距离
margin是描述本view和其他(上下左右)的view之间的距离

<?xml version="1.0" encoding="utf-8"?>  
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
    android:orientation="vertical"  
    android:layout_width="fill_parent"  
    android:layout_height="fill_parent"  
    android:paddingLeft="10dip"  
    android:paddingRight="10dip"  
    android:paddingTop="10dip"  
    android:paddingBottom="10dip"  
    >  
<TextView    
    android:layout_width="wrap_content"   
    android:layout_height="wrap_content"   
    android:background="#FF0000"  
    android:text="@string/hello"  
    android:paddingLeft="50dip"  
    android:paddingRight="50dip"  
    android:paddingTop="50dip"  
    android:paddingBottom="50dip"  
    android:layout_marginBottom="10dip"  
    />  
    <TextView    
    android:layout_width="wrap_content"   
    android:layout_height="wrap_content"   
    android:background="#FF0000"  
    android:text="@string/hello"  
    android:paddingLeft="50dip"  
    android:paddingRight="50dip"  
    android:paddingTop="50dip"  
    android:paddingBottom="50dip"  
    android:layout_marginBottom="10dip"  
    />  
    <TextView    
    android:layout_width="wrap_content"   
    android:layout_height="wrap_content"   
    android:background="#FF0000"  
    android:text="@string/hello"  
    android:paddingLeft="50dip"  
    android:paddingRight="50dip"  
    android:paddingTop="50dip"  
    android:paddingBottom="50dip"  
    android:layout_marginBottom="10dip"  
    />  
    <TextView    
    android:layout_width="wrap_content"   
    android:layout_height="wrap_content"   
    android:background="#FF0000"  
    android:text="@string/hello"  
    android:paddingLeft="50dip"  
    android:paddingRight="50dip"  
    android:paddingTop="50dip"  
    android:paddingBottom="50dip"  
    android:layout_marginBottom="10dip"  
    />  
</LinearLayout>  

结果如图:
这里写图片描述

注意:
1.android:layout_margin:本view离父容器上下左右间的距离
2.android:padding: 是本view里面的内容离本view的上下左右边的距离
3.android:layout_marginStart=”100px” 指外边距,当前控件距离父控件起始位置100px
4.android:paddingStart=”100px” 指内边距,控件里面的内容到控件的起始位置的距离为100px

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值