Dip:device independent pixels (device 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.
DP: Same as dip.
Px:pixels (pixels), a pixel is usually considered as the smallest full sample of the image, different devices display the same effect, generally we hvga represent 320x480 pixels, this use more.
Pt:point, is a standard length unit, 1pt=1/72 inches, for the printing industry, very simple to use.
sp:scaled pixels (enlarge pixels). Mainly used for font display of best for textsize.
In: (inches): unit of length.
Resolution: Divided into display resolution (screen resolution) and image resolution.
Display resolution: The precision of the screen image refers to the number of pixels the display can display. The more pixels the display can display, the finer the picture will be. The display resolution is certain, the smaller the display, the clearer the image, conversely, when the display size is fixed, the higher the display resolution, the clearer the image.
Image resolution: The number of pixel points that are contained in units of inches.
The relationship between MDPI and hdpi is 2:3.
The relationship between MDPI and xhdpi is 1:2.
The relationship between ldpi and MDPI is 3:4.
DP and PX Conversion formula:
Pixs =dips * (densitydpi/160).
Dips= (pixs*160)/densitydpi
Now suppose, in a project, you put a picture of a 60px*60px in the MDPI, its size is 60*60;
If take it to hdpi, then its size should be 40*40, picture shrinks.
First, Android the screen knowledge in
Pixels: (px) Each picture is composed of color points, each color point is a pixel, the size of the pixel can be changed, so also become "relative length", the camera said the pixel, the actual maximum number of pixels, such as 2 million = 1600 * 1200, Pixels are determined by the number of photosensitive elements on the photoelectric sensor in the camera, and a photosensitive element corresponds to one pixel. Therefore, the larger the pixel, means that the more photosensitive components, the corresponding cost is greater.
Screen Resolution: Is the number of pixels per row of the screen * pixel points per column; The resolution of the phone is determined at the factory and cannot be changed.
Image resolution: The number of pixels in an image per inch. Image resolution is a unit, called pixels per unit (px/in);
Screen Size: Only the physical length of the screen diagonal, immutable, in inches (in);
Screen pixel density: (PPI) refers to the number of pixels per inch on the diagonal of the screen; at normal distances, when the PPI is above 300, the human eye cannot discern the pixels.
Second, about the pixel size
The size of the pixel is not fixed, however, an electronic device, the factory screen resolution and the physical size of the pixel is determined.
Why can my Computer adjust the screen resolution?
The actual resolution of the computer is the maximum resolution, while adjusting to a smaller resolution, the actual resolution of the screen by filling some of the analog color block, the resolution to the actual hardware.
Third, developer adaptation
There will be DP (DIP), px, dpi, density in Android.
Dip: Is DP, device-independent pixels;
PX: pixels, but more introduction;
Dpi:dots per inch, pixel count, also known as pixel density (px/inch);
Density: density, density = actual dpi/standard dpi, i.e. actual dpi/160;
By definition, when the DPI is 160, the DP equals PX, we have to 1DP = 160*1inch;
Also dpi defined: 1px = 1dpi*1inch;==>1px = 1dpi* (1dp/160) = (1dpi/160) *1DP;
So, the conversion formula for DP and PX is:
1DP = px/(dpi/160) = (px*160)/dpi = px/density;
1px = DP * (dpi/160) = DP * density;
Summarize
120DPI (ldpi low-density screen) 1DP = 0.75px (Standard: 320*240) (Because the pixel is a physical point, so the content of 3 DP is displayed with 2 pixel points)
160DPI (mdpi medium density screen) 1DP = 1px (standard: 480*320)
213DPI (tvdpi TV density screen) 1DP = 1.33px
240DPI (hdpi high-density screen) 1DP = 1.5px (standard: 800*480)
320DPI (xhdpi Ultra high-density screen) 1DP = 2px (standard: 600*124)
Picture adaptation
Follow the medium density screen to give the UI, and then put in a different dpi picture folder;
Size adaptation
In the values file at different dpi, convert by formula
Android Unit Size understanding