[Turn + finish] Android resolution, density, pixel unit description

Source: Internet
Author: User

Android supports all of the following units:

PX (pixels): A point on the screen. 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. is a standard length unit for the printing industry, very simple to use;

DP (DIP) (density independent pixels): An abstract unit based on screen density. is not related to pixels. 1DP = 1px on a monitor 160 dots per inch.

SP (scale independent pixels): Mainly used for font display. According to Google's suggestion, TextView's font size is best to use SP to do units, and view the source of TextView know that Android by default using the SP as the font size units.

DP and SP are Android Ritter, designers do UI design is usually initially built 320*480 this size of the canvas started, this size of the canvas in the classification of Android resolution is called MDPI, in this size, PS 1px is equal to the 1DP in Android, similarly, this time 1 points of the word equals Android 1SP, for example: you build a canvas size is 320-480, the text inside is 30 points, then it is 30sp.

Resolution: The whole screen is how many points, such as 480*800, it is for the software to display units, in PX units of the point.

The density (density) value represents the number of display points per inch, and the resolution is two concepts.

APK in the resource bundle,

Resources that use HDPI tags when the screen is density=240
Resources that use MDPI tags when the screen is density=160
When the screen density=120, use the ldpi tag resource.
General Android Set length and width multi-use dip, set font size multi-use SP. The screen density is 160,1dp=1px=1dip, 1pt = 160/72 sp 1pt = 1/72 inches. When the screen density is 240, 1dp=1dip=1.5px.

To illustrate:

For a WVGA (480x800) Phone (G7, N1, NS), it is generally run in hdpi mode. When running in hdpi mode, 1dp=1.5px: That is, the designer defines an item in PS high 72px, development will define the item high 48dp;photoshop 21px font, development will be defined as 14SP.

Extended reading: Android interface design terminology: XXXHDPI and 4K resolution

Android's resolution is similar to iOS, it has four pixel density, Android offers 120DPI (Low density), 160DPI (medium density), 240DPI (high Density) and 320DPI (ultra high density), all user interface is based on the size of one of four density to design. It is tragic to support all 4 densities. If you start with a 160DPI design, you need to extend these densities to 100%, 150%, and 200%.

In order for the user UI interface to display properly on the current and future mobile display types, it is recommended that you always use the SP as the unit of text size on the Android system and dip as the unit of other elements.

[Turn + finish] Android resolution, density, pixel unit description

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.