google的android文档里的解释:

public static final int padding

Since: API Level 1

Sets the padding, in pixels, of all four edges. Padding is defined as space between the edges of the view and the view's content. A views size will include it's padding. If a background is provided, the padding will initially be set to that (0 if the drawable does not have padding). Explicitly setting a padding value will override the corresponding padding found in the background.

Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), mm (millimeters).

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

Constant Value: 16842965 (0x010100d5) 再看margin,以marginBottom 举例

android:layout_marginBottom

Since: API Level

Specifies extra space on the bottom side of this view. This space is outside this view's bounds.

Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), mm (millimeters).

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol layout_marginBottom.

Related Methods
  • setMargins(int,int,int,int)

所以padding是定义控件自己的内容和控件边缘之间的距离,padding有填充填料的意思,而margin是在说控件的四个边缘之外的距离,指的是和别的控件之间的距离,margin有边缘,页面留白的意思

借用一幅别人的图来说明

android的布局属性中padding和margin的区别_第1张图片

更多相关文章

  1. Android 控件界面转成Bitmap
  2. android UI控件之webview控件使用实例:加载网页到webview中
  3. Android - 获取控件(包括状态栏与标题栏)宽高
  4. android获取控件宽高
  5. android日期控件显示
  6. Android 复用自制的控件(2)
  7. Android控件之——输入框TextInputLayout、TextInputEditText的
  8. android scrollview滑动时悬浮部分控件
  9. Android控件属性android:fitsSystemWindows="true"的坑

随机推荐

  1. Android中的popupwindow从底部进入和退出
  2. Android之ActivityGroup实现Tab功能 (转)
  3. 应用程序基础知识:activity和intent——An
  4. Android(安卓)Windows 开发环境搭建教程
  5. Android(安卓)工具类之--TextUtils
  6. Android(安卓)CardView 设置点击效果
  7. Android 实现书籍翻页效果---番外篇之光
  8. Android(安卓)Volley 简单分析
  9. 开发前奏曲之添加Android(安卓)SDK平台工
  10. AndFix解析——(上)