Summary of Android screen density, dip and other related concepts

Source: Internet
Author: User

1. Several terms
VGA, HVGA, QVGA, WVGA, WQVGA
These terms refer to the screen resolution.
VGA: Video Graphics Array: displays the drawing matrix, which is equivalent to 640x480 pixels;
HVGA: Half-size VGA; that is, Half of VGA, resolution: 480 × 320;
QVGA: Quarter VGA; that is, 1/4 of VGA, resolution: 320 × 240;
WVGA: Wide Video Graphics Array; that is, expanded VGA with a resolution of 800x480 pixels;

WQVGA: Wide Quarter VGA; that is: Expanded QVGA, resolution is higher than QVGA, lower than VGA, generally: 400 × 240,480 × 272;

Common Resolution types are listed below.
QVGA = 320*240; WQVGA = 320*480; WQVGA2 = 400*240; WQVGA3 = 432*240; HVGA = 480*320; VGA = 640*480; WVGA = 800*480; WVGA2 = 768*480; FWVGA = 854*480; DVGA = 960*640; PAL = 576*520; NTSC = 486*440; SVGA = 800*600; WSVGA = 1024*576; XGA = 1024*768; XGAPLUS = 1152*864; HD720 = 1280*720; WXGA = 1280*768; WXGA2 = 1280*800; wxga = 1280*854; SXGA = 1280*1024; WXGA4 = 1366*768; SXGAMINUS = 1280*960; SXGAPLUS = 1400*1050; WXGAPLUS = 1440*900; HD900 = 1600*900; WSXGA = 1600*1024; WSXGAPLUS = 1680*1050; UXGA = 1600*1200; HD1080 = 1920*1080; QWXGA = 2048*1152; WUXGA = 1920*1200; TXGA = 1920*1400; QXGA = 2048*1536; WQHD = 2560*1440; WQXGA = 2560*1600; QSXGA = 2560*2048; QSXGAPLUS = 2800*2100; WQSXGA = 3200*2048; QUXGA = 3200*2400; qsxhd = 3840*2160; WQUXGA = 3840*2400; HD4K = 4096*2304; HXGA = 4096*3072; WHXGA = 5120*3200; HSXGA = 5120*4096; WHSXGA = 6400*4096; HUXGA = 6400*4800; SHV = 7680*4320; WHUXGA = 7680*4800;


Px :( pixels) (pixel): the point on the screen, indicating the actual pixel of the screen, which is related to the density. The density is high, and the px size per unit area is large. For example, 320*480 screens have 320 pixels horizontally and 480 pixels vertically.

Dip or dp (pixels unrelated to density ). This is related to the hardware of the device. We recommend that you use this feature to support WVGA, HVGA, and QVGA 5 hexadecimal space. An abstract unit based on screen density. You can use this option to set the width and height of some views. Generally, you do not feel scaled at different resolutions.

Formula for converting px and dip:
Px = (density/160) * dip density is generally 3 common fixed values: 240/160/120

ScaledDensity (font scaling ratio ). That is, the conversion value of the unit sp. It is generally used to set the font size.
Sp zoom-mainly deal with the font size. Dp is not related to density. sp is not only related to density, but also to scale.
Sp and px conversion formula:

DisplayMetrics dm = new DisplayMetrics();getWindowManager().getDefaultDisplay().getMetrics(dm);pixelSize = (int)scaledPixelSize * dm.scaledDensity; 
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
Pt: indicates a point. It is a physical length of 1 inch of the screen size.
Density: specifies the number of pixels that can be displayed within the physical width and height range based on the pixel resolution. Generally, the number of pixels that can be displayed is 1 inch.


2. Some parameters
Common mobile phone screen resolutions (I hope you can add them)
Xiaomi 3
Density = 3.0, width = 1080, height = 1920, scaledDensity = 3.0, xdpi = 449.704, ydpi = 447.412
Xiaomi 2
Density = 2.0, width = 720, height = 1280, scaledDensity = 2.0, xdpi = 345.0566, ydpi = 342.23157
Meizu 3
Density = 2.5, width = 1080, height = 1800, scaledDensity = 2.5, xdpi = 415.636, ydpi = 415.636
Samsung s3
Density = 2.0, width = 720, height = 1280, scaledDensity = 2.0, xdpi = 304.8, ydpi = 306.716
Motorola Me525 Android2.2.2
Density = 1.5, width = 480, height = 854, scaledDensity = 1.5, xdpi = 144.0, ydpi = 144.0


Screen size and density
Screen width Height size Density
Type (Pixels) Range (inches) Size Group

QVGA 240 320 2.6-3.0 Small Low
WQVGA 240 400 3.2-3.5 Normal Low
FWQVGA 240 432 3.5-3.8 Normal Low
HVGA 320 480 3.0-3.5 Normal Medium
WVGA 480 800 3.3-4.0 Normal High
FWVGA 480 854 3.5-4.0 Normal High
WVGA 480 800 4.8-5.5 Large Medium
FWVGA 480 854 5.0-5.8 Large Medium

3. Some useful code

Mport android. content. context; import android. util. displayMetrics;/*** formula pixels = dips * (density/160) ** @ version 1.0.1 2010-12-11 ** @ author */public class DensityUtil {private static final String TAG = DensityUtil. class. getSimpleName (); // The densityDpiprivate static float dmDensityDpi = 0.0f; private static DisplayMetrics dm; private static float scale = 0.0f; /***** obtain the screen coefficient of the current Mobile Phone Based on the constructor ***/public DensityUtil (Context context) {// obtain the current screen dm = new DisplayMetrics (); dm = context. getApplicationContext (). getResources (). getDisplayMetrics (); // sets DensityDpisetDmDensityDpi (dm. densityDpi); // The density factor: scale = getDmDensityDpi ()/160; Logger. I (TAG, toString ();}/*** density Factor of the current screen ** @ param DmDensity * @ retrun DmDensity Getter **/public static float getDmDensityDpi () {return dmDensityDpi;}/*** density Factor of the current screen ** @ param DmDensity * @ retrun DmDensity Setter **/public static void reset (float dmDensityDpi) {DensityUtil. dmDensityDpi = dmDensityDpi;}/*** density conversion pixel **/public static int dip2px (float dipValue) {return (int) (dipValue * scale + 0.5f );} /*** pixel conversion density **/public int px2dip (float pxValue) {return (int) (pxValue/scale + 0.5f);} @ Overridepublic String toString () {return "dmDensityDpi:" + dmDensityDpi ;}}



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.