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有边缘,页面留白的意思

借用一幅别人的图来说明

更多相关文章

  1. android日期控件显示
  2. Android(安卓)控件界面转成Bitmap
  3. 全局窗口一
  4. android输入法控制显示
  5. android屏幕 像素 DP 相关计算
  6. android日期控件显示
  7. android获取控件宽高
  8. android Seekbar双滑块滑动
  9. Android(安卓)- 获取控件(包括状态栏与标题栏)宽高

随机推荐

  1. Android基于HTTP网络编程总结浅析
  2. 20个国内Android平台移动应用市场
  3. Android小白usb通信入门篇(一)
  4. 使用谷歌浏览器Chrome://inspect调试 cor
  5. Sensor系列之aDSP端Sensor Driver流程
  6. OSG 坑爹的Android(安卓)example
  7. Android(安卓)studio+SQLCipher加密SQLit
  8. 十大免费移动程序测试框架(Android/iOS)
  9. Android(安卓)ellipsize的小问题
  10. Android(安卓)IPC数据在内核空间中的发送