After doing a small software, finally the margin and padding clear, now summarized as follows:
The margin and padding of Android are the same as in HTML. As shown: The yellow part is padding and the gray part is margin.
Popular understanding Padding is the inner border, margin is the outer box
The corresponding properties are:
12 3 456 78 android:paddingbottom= "1dip"
If both the left and right settings are the same, you can set them directly:
12 android:padding= "5dip"
Length units supported by Android:
- PX (pixels): The point on the screen.
pixels (pixels). Different devices show the same effect, generally we hvga represent 320x480 pixels, this use more.
- In (inches): unit of length.
- MM (mm): unit of length.
- PT (lb): 1/72 inches.
Point, is a standard length unit, 1pt=1/72 inches, for printing, very simple to use;
- DP (density-independent pixels): An abstract unit based on screen density. 1DP = 1px on a monitor 160 dots per inch.
- Dip: Same as DP, more for android/ophone example.
device independent pixels (unit independent pixels). Different devices have different display effects, this is related to the device hardware, generally we support WVGA, HVGA and QVGA recommend this, do not rely on pixels.
- SP (scale independent pixels): Similar to DP, but can be scaled based on the user's font size preference.
scaled pixels (enlarge pixels). Mainly used for font display of best for textsize.
In order for the user interface to display properly on the current and future display types, it is recommended that you always use the SP as the text size unit, and the Android default font size is also used by the SP.
The dip is used as a unit of other elements, such as length and height. Of course, you can also consider using vector graphics instead of bitmaps.
In order for the user interface to display properly on the current and future display types, it is recommended that you always use the SP as the text size unit, and the Android default font size is also used by the SP.
The dip is used as a unit of other elements, such as length and height. Of course, you can also consider using vector graphics instead of bitmaps.
This blog summarized in: http://www.cnblogs.com/ghj1976/archive/2011/04/26/2029648.html
Android margin and padding attributes and supported length units