Android technology 1: dimension Unit analysis, android size

Source: Internet
Author: User

Android technology 1: dimension Unit analysis, android size

Yesterday, Alibaba's telephone interview showed me a lot of deficiencies, and I didn't pay much attention to many small knowledge points at ordinary times. Well, the first blog will analyze various size units in android.

Technology 1:

"What are the specific differences between many size units in Android"

 

1. dimension type

Dip, px, pt, sp, dp

Dip: (device indepedent pixels) Independent pixels of the device (which is not related to the density and can be scaled with the density). Different devices are displayed differently, which is related to the device, it depends on the number of dpi dots per inch. dip is recommended.

Px :( pixels) pixels are displayed in the same size on different devices. Therefore, devices with different resolutions have different sizes for android devices, and the layout is greatly affected. We recommend that you do not use px.

Pt :( points) lbs. It is physical size, 1pt = 1/72 inch, general user printing industry.

Sp :( scaled pixels): the pixels that can be zoomed in are irrelevant to the scale. sp is recommended for general font sizes in Android, and 1pt is approximately 2.22sp in android.

Dp: similar to dip, if the screen density is 160dip (160 points per inch) 1px = 1dp.

2. dip and px Conversion

We know that dip is irrelevant to screen density. px = dip x indicates the actual screen density/160.

Dip has an adaptive screen density, which changes the pixel size of the actual control as the screen density changes. As a result, the display is eventually converted to px display.

For example, in density = 160dip and the screen size remains unchanged, 1px = 1dip.

If one density is dip and the other 320dip is the same as the screen size, if the button width is PX, the button size changes with the screen density, the button size seems to be half of the original density in high density, and cannot be self-adaptive.

If one density = 160dip and the other 320dip have the same screen size, if the button width uses 160dip, the button size does not change with the screen density, which is consistent with the actual size, however, in high density, buttons are displayed more delicate.

3. density

The density (density) value indicates the number of display points per inch, and the resolution is two concepts. Different from the resolution, the screen size varies with the resolution, resulting in different density.

The total number of pixels on the physical screen. Similar to the size, there are also four types: low, medium, high, super high, and the android project corresponds to the drawable-four dip

WVGA 800*480 hdip, VGA 640x480 HVGA 480x320 mdip, QVAG 320x240 ldip,
Note that different resolutions in the res/drawable-_ dip directory correspond to different drawable, and the system loads different drawable values based on different resolutions on the System screen.

Ldpi: Mobile Phone devices with a screen density of 120
Mdpi: A mobile phone device with a screen density of 160 (this is baseline, others are based on this, on this device, 1dp = 1px)
Hdpi: Mobile Phone devices with a screen density of 240
Xhdpi: A mobile phone device with a screen density of 320
Xxhdpi: Mobile Phone devices with a screen density of 480

4. Resolution

Resolution refers to the total number of pixels on the screen. Note that although the resolution is expressed as "width x length" in most cases, the resolution does not mean the aspect ratio of the screen. In Android systems, the program generally does not directly process the resolution.

 


What is the unit of length in Android? What are their differences? Details

Dp and sp
Px: the actual pixel of the screen. For example, 320*480 screens have 320 pixels horizontally and 480 pixels vertically.

In: indicates the inch, which is the physical size of the screen. Each inch equals 2.54 cm. For example, the screen size of a mobile phone is often described as 3.2 (English), 3.5 (English), and 4 (English. These dimensions are the diagonal length of the screen. If the phone screen is 3.2 inch, the diagonal line length of the phone screen (visible area) is 3.2*2.54 = 8.128 cm. You can measure your mobile phone screen to see if the size is the same as the actual size.

Mm: Indicates mm, which is the physical size of the screen.

Pt: indicates a point, which is the physical size of the screen. The size is 1 inch of 1/72.
Original post address www.ophonesdn.com/forum/thread-1946-2-1.html

Px (Pixels, Pixels): corresponds to the actual Pixels on the screen. For example, 320*480 screens have 320 pixels horizontally and 480 pixels vertically.

In (Inches, Inches): The physical length unit of the screen. Each inch equals 2.54 cm. For example, the screen size of a mobile phone is often described as 3.2 (English), 3.5 (English), and 4 (English. These dimensions are the diagonal length of the screen. If the phone screen is 3.2 inch, the diagonal line length of the phone screen (visible area) is 3.2*2.54 = 8.128 cm. You can measure your mobile phone screen to see if the size is the same as the actual size.

Mm (Millimeters, mm): physical length unit of the screen.

Pt (Points, lbs): the unit of physical length of the screen, indicating a point. It is the physical size of the screen. The size is 1 inch of 1/72.

Dp (density-independent pixels): the unit of logical length. On a 160 dpi screen, 1dp = 1px = 1/160 inch. As the density changes, the number of corresponding pixels also changes, but there is no direct change ratio.
Dip: it is the same as dp and is mostly used in Google examples.
Sp (pixels unrelated to density and font ZOOMING): similar to dp, but can be scaled based on your font size preferences.

Use dp as the unit of space size and sp as the unit of text size.

What is the unit of 2 "x 1 1/2"

It should be an inch ~
1 inch = 2.54 cm

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.