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有邊緣,頁面留白的意思
借用一幅别人的圖來說明
![](https://img.laitimes.com/img/_0nNw4CM6IyYiwiM6ICdiwiIml2ZuEjMxczM5IjNxMjM0ATMx8CX0AzXxEDMy8CXkF2bsBXdvwVbvNmLjRWa4VnbpxmL3d3dvw1LcpDc0RHaiojIsJye.gif)