Size Issues in Android design

Source: Internet
Author: User

Android divides the screen size into four types: small, normal, large, xlarge;
The screen density is divided into: low (LDPI), Medium (MDPI), High (hdpi), Extra High (xhdpi), and the relationship between each screen density such as the following:

Reference
Density namevalue for density (DPI) Relationship the corresponding screen resolution
xxxhdpi 640dpi
xxhdpi 480dpi
xhdpi 320dpi 2.0
hdpi 240dpi 1.5 800*480
mdpi 160dpi 1.0 (Benchmark) 480*320
ldpi 120dpi 0.75 320*240

DPI (dot per inch): The number of pixels per inch, 1 inches = 2.54 centimeters, 4.3 inches, 4.5 inches is actually the length of the screen diagonal.

DP (density independent pixel): independent density pixels, using DP as the unit to set the control, no matter how large the screen or DPI, its display is consistent; If you use PX, you will see inconsistent results. For example, for a line length of 160px, at a density of 160dpi. A screen with a width of 1 inches fills the entire screen, while on a screen with a density of 320dpi and a width of 1 inches. It just fills half the screen. That is, for the two physical dimensions of the same, but different DPI screen, its display effect will be very large.

Pixel, DP, DPI relationships such as the following:

PX = DP * (dpi/160)

principle 1: When transduction the Android interface. 160DPI is generally used as a benchmark . Due to the 160DIP as a benchmark, only to cut the length and width of the number of pixels is a multiple of 4, then xhdpi the number of pixels on the length and width of the image can be multiplied by 2,hdpi multiplied by 1.5,ldpi multiplied by 0.75. As a result, the number of pixels on the resulting width is integers. Assuming that the 240dpi as a benchmark, then the number of pixels in the 240-slice length width should be a multiple of 3, corresponding to the xhdpi multiplied by 1.333333,mdpi under the 0.66666,ldpi divided by 2, which will get the number of non-shaping pixels.

QVGA, the screen density of WQVGA is: 120
The screen density of the HVGA is: 160
The screen density of the WVGA is: 240
Of LDPI resources are not required when hdpi resources are provided. The system will voluntarily reduce hdpi resources by half to fit the ldpi screen

Note: Screen density and screen resolution are different concepts, with screen resolution and size, can calculate the screen density , such as the resolution of 320*480, screen size is 3.2 inches (diagonal length). The screen density is:

Density = \frac{\sqrt{320^2+480^2}}{3.2} ">

Note: Dip is DP

SP (scale independent pixel): scaling independent pixels. Similar to DP, the only difference is. The unit is affected by the system font settings and is often used on fonts. The regular use of font size as specified in the Android specification:

Displaymetrics class

Displaymetrics is a class used to describe the relevant parameters of a screen. How to access Displaymetrics:

DisplayMetrics metrics = new DisplayMetrics();getWindowManager().getDefaultDisplay.getMetrics(metrics);

You can then access the constants, fields, and methods in the metrics variable.

  • Density: Screen density
  • DENSITYDPI: Screen density, in dpi
  • Heightpixels: screen height, in pixels
  • Widthpixels: Screen width, in pixels
  • XDPI: Screen density in X-direction of the screen
  • YDPI: Screen density in the Y-direction of the screen
Market data

Top-ranked screen resolutions:

resolution percent screen density
1280 * 720 29.2% 267 ~ 293 (hdpi, xhdpi)
800 * 480 18.5% 233 ~ 266 (HDPI)
854 * 480 13.8% 195 ~ 217 (MDPI, hdpi)
1920 * 1080 10.6% 367 ~ (xhdpi)
960 * 540 10% ~ 244 (HDPI)
480 * 320 4.1%
1184 * 720 3%

Data Source: Http://www.umindex.com/devices/android_resolutions

RELATED LINKS
  1. Https://developer.android.com/design/style/devices-displays.html
  2. Http://developer.android.com/training/basics/supporting-devices/screens.html
  3. Http://www.25xt.com/allcode/4269.html

Size Issues in Android design

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.