Design principles to follow when designing Android UI

Source: Internet
Author: User

1, Android device screen size distribution

First look at the size of various screens and screen density division. is the appropriate range for various screen sizes:

From the can see, the corresponding normal size screen range is concentrated in the common between 3 to 5 inch screen, large size corresponding to the main is 5 to 7 inch nottpad such equipment, such as Samsung's note and NEXUS7 tablet, and then go online is a tablet computer.

Next is the screen density (dpi), which needs to be explained. In fact, the screen resolution can not be used as the basis for screen adaptation, should be based on screen density and screen size to be converted, screen density refers to the number of pixels per inch screen, screen density from ldpi to xhdpi respectively 120dpi, 160dpi, 240dpi, 320dpi, The higher the screen density, the higher the resolution, and the smaller the screen size, the retina screen is created.

in screen fitting, Google recommends designing for MDPI (160dpi) and scaling it proportionally. Such methods are mainly for bitmaps (some irregular pictures, images that cannot be stretched, other recommended use. 9), with MDPI as the baseline. and scale in 3:4:6:8:

2. Android Resource File

DRAWABLE-HDPI contains high-resolution images, such as WVGA (480x800), FWVGA (480x854)
DRAWABLE-MDPI contains medium-resolution images such as HVGA (320x480)
DRAWABLE-LDPI contains low-resolution images, such as QVGA (240x320)

3. Common units of measure on Android

PX (pixels): The point on the screen, absolute length. Related to hardware.

In (inches): unit of length.

MM (mm): unit of length.

PT (LB): 1/72 inch, point.

DP (density-independent pixels): An abstract unit based on screen density.

1DP = 1px on a monitor 160 dots per inch.

Dip:density-independent pixel, same as DP.

SP: On the basis of DP. It is also independent of the scale and is understood by the individual as a vector graphic unit.


Defines the size in XML. It is recommended that TextView use SP, other use DP

corresponding Relationship

Android phone screen standard corresponding icon size standard screen density

xhdpi 1280*720 96*96 320

HDPI 480*800 72*72 240

MDPI 480*320 48*48 160

LDPI 320*240 36*36 120

all the corresponding information at different resolutions on the simulator :

QVGA: {density=0.75, width=240, height=320, scaleddensity=0.75, xdpi=120.0, ydpi=120.0}
HVGA: {density=1.0, width=320, height=480, scaleddensity=1.0, xdpi=160.0, ydpi=160.0}
WVGA: {density=1.5, width=480, height=800, scaleddensity=1.5, xdpi=240.0, ydpi=240.0}

The density is the logical resolution of the display, and the width and height are the screen resolution (absolute width and height), consistent with the Widthpixels and heightpixels in fields; scaledensity and density; xdpi and ydpi are pixel densities in the X and y directions .

4. How to calculate density (dpi)

1. The standard is 240*320 painted on the 1.5*2 square inch. So like every square inch has 240*320/(1.5*2) = 25,600 points. That is, a square-inch pixel point is 25600. So the DPI takes its square root 160, assuming that your DPI is 120, then its density is 0.75.

2. Density is not only related to width, but also to height, so whether width is 1.8 or 1.3. Its density is likely to be 1. For example, width is 1.8. Only if its height is 3/1.8, suppose Pixel is 240*320. Its density is still 1, the same assumption width is 1.3. Only if its height is 3/1.3, the pixel point is 240*320, then the density is also 1.

3.320*480/(1.5*2) Gets the point of the unit square inch is 51200, so the unit square inch is the 240*320 painted on the 1.5*2 screen twice times.

But this is square inches ah, the density of the time to open the square ah, so should be 2 square, is 1.414 bar, the approximate density of 1.5.

5, PX and dip of the relationship

Android. In 160dpi (MDPI), 1 dip= 1 px;

And so on, in 120dpi (ldpi), 1 dip = 0.75px;

In 240dpi (hdpi), 1 dip = 1.5px;

In 320dpi (xhdpi), 1dip = 2px.

6, how to achieve density-independent

Assuming a screen density of 160, the DP and SP and PX are the same. 1dp=1sp=1px. But suppose you use PX as a unit. Suppose the screen size is the same (assuming 3.2 inches), and the screen density becomes 320.

So the width of the original TextView is set to 160px. The 3.2-inch screen with a density of 320 looks half as short as a 3.2-inch screen with a density of 160. But suppose it is set to 160DP or 160SP. The system will voluntarily set the value of the Width property to 320px. That means 160 * 320/160. 320/160 can be called the density scale factor. That is, assuming that the DP and SP are used, the system will actively convert itself based on the change in screen density. The Official document summary is calculated as: pixels = DPS * (density/160).

Dip is used as the unit of view so that it can be compatible with a wide range of resolutions at the same time. Does not cause the UI to be incompatible.




Design principles to follow when designing Android UI

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.