Android Units of Measurements
Posted on 26 May, 2019 by Administrator
Today we well discuss about Android units of measurements like: px, in, mm, dp, dip and sp ...
1. What is Pixel - px:
Pixel, PX, or even called pel (derived from "picture element"), we usually called pixels, is square.
An image bitmap that you see on screen is two-dimensional matrix (2D) of pixels make up (or matrix of small squares). Each pixel occupies one position in the matrix and contains one part of the picture display. Each pixel contains only one color combination from 3 primary colors Red, Green, Blue.
Pixel is often used to talk about the resolution (resolution) of the device.
For example: Samsung Galaxy S3 screen resolution of 1280 × 720 (Height x Width). This means that the height of the screen is 1280 pixels Galaxy S3, and the width is 720 pixels.
Devices with higher resolution screens are more and more pixels. However this is not to say that the screen will show you beautiful images. This depends on the area of the screen, so the pixel is not used as a unit of measurement of the screen size the device, but it is used to measure the size of the image.
2. Dp, or dip or Density-independent Pixels, sometimes called Device-independent Pixels:
This is a measure of the physical length, like inches, cm, mm ... but Google often used to measure the size of the device screen. (The iOS user have point pt or similar concept with dp).
160 dp = 1 inch - this means = 1/160 = 0.00625 inch 1dp.
1 dp may contain one or more pixels.
As the example image above 10dp in low resolution screen equivalent 1dp 1 pixel. On average, the resolution equivalent 1dp 4 pixels ...
3. DPI - Dots per inch, or ppi - Pixels per inch:
Note that dp or dip should not be confused with the dpi (dots per inch).
Dots per inch is the number of pixels (pixels) on 1 inch of display devices, this number the larger the display screen equipment as smooth and beautiful photos.
Based on one divided dpi screen type as follows:
- Small: ldpi (120dpi)
- Normal: mdpi (160dpi)
- Large: HDPI (240dpi)
- X-large: xhdpi (320dpi).
With this type 1 dp each corresponding to the number of different pixels, is calculated using the formula:
PX = dp * (dpi / 160)
For example the device is 320 dpi with 10-dp then we get: 10 * (320/160) = 20 PX, 1 or 2 PX dp.
|Model||Screen Size Inch||Screen Size Cms||Resolution Pixels||Pixel Density PPi|
|Samsung Galaxy S6||5.1||12.95||1440 x 2560||571|
|LG G3||5.5||13.97||1440 x 2560||534|
|Samsung Galaxy Note 4||5.7||14.48||1440x2560||515|
|Nexus-6||5.96||15.14||2560 x 1440||493|
|HTC One M8||5||12.7||1080 x 1920||441|
|Samsung Galaxy S5||5.1||12.95||1080x1920||432|
|Sony Xperia Z3||5.2||13.21||1080x1920||424|
|iPhone-6 Plus||5.5||13.97||1080 x 1920||401|
|Lumia 1520||6||15.24||1080 x 1920||367|
|iPhone-6||4.7||11.94||750 x 1334||326|
4. PT – Point:
PT - which stands for Point, concept similar dp pt is a unit measuring the actual size, but differ with dp:
1 pt = 1/72 inch, while 1 dp = 1/160 inch
pt often used in iOS programming.
5. SP – Scale-independent Pixels:
Similar to dp, but sp commonly used for the text font size.
The following are examples of normal screen display mdpi (160dpi) for the unit of measurement dp, sp, PX, pt, inch.
New blog posts
8 June, 2019 by Administrator
1. String data type All programming...
2 June, 2019 by Administrator
1. Value and type Value is one of...
31 May, 2019 by Administrator
1. What is Python: Python is an Interpreter...