Android margin and padding attributes and supported length units

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.