Mobile APP test: Android screen adaptation Question two

Selective design layout and pictures, needs the type of alternative resources, depending on the application. Typically, the size and orientation of qualifiers should be used to provide selective resource layout using qualifiers provide selective image density resources. The following sections summarize how the size and density qualifiers provide selective layouts and graphics. (Source: Thousand Feng software testing)

Selective layout should ensure that the layout of the application:

· Fit on a small screen (make sure that you can actually use)

· On the big screen, to ensure full use of the extra screen space

· Adaptation portrait and landscape

If the user interface, you need to make way for size (such as a button background image) plans to adapt the view, you should use Nine-Patch bitmap file. Nine-Patch file is basically a PNG file which can be extended in certain two-dimensional region. When the system needs to view bitmaps where the stretching, the stretching Nine-Patch system files, but only the designated area is drawn. Because of this, no need to provide different pictures of different screen sizes, because the Nine-Patch bitmap can be adjusted to any size. However, it should provide different Nine-Patch files for different screen density.

Selective Pictures

cb48accd49034c20897d1531257baca4.png

Figure 4. supports relative size of the bitmap for each density

Almost every application for different screen densities provide images resources should be, because almost every application has a startup icon, and change the icon should appear well on different screen densities.

NOTE: Density only provide bitmap file (.png, .jpg, or .gif) Nine-Path and file (.9.png). If you need to use XML to define the shape, color or resources can be drawn, it should be backed up at a default drawable directory.

To create a different picture of the density of selectivity, should follow the four generalized densities between 3: Scaling 8: 4: 6. For example, at a density of 48x48 pixel bitmap (icon application start), all the different sizes corresponding should be:

· Low density is 36x36

· Density is 48x48

High density 72x72

· Ultra-high density 96x96 

Configuration Example

For your design for different types of devices, here are some of the typical digital screen width:

· 320dp: a typical mobile phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc.).

· 480dp: Streak as neutral as flat screen (480x800 mdpi).

· 600dp: 7 "tablet (600x1024 mdpi).

· 720dp: 10 "tablet (720x1280 mdpi, 800x1280 mdpi, etc.).

2 size qualifiers, the application can use any width you want and / or height between the phone and tablet to switch between different layouts using a resource table. For example, if the layout is a flat plate supported 600dp smallest available width, the layout of the two sets may be provided:

res/layout/main_activity.xml           # For handsets
res/layout-sw600dp/main_activity.xml   # For tablets

In this case, in order to allow plate layout practical minimum width of the available screen space must be 600dp.

To further customize the size of the UI to distinguish, as in the case 7 "and 10" flat, the minimum width may define additional layout:

res/layout/main_activity.xml          

res/layout-sw600dp/main_activity.xml  

res/layout-sw720dp/main_activity.xml  

Note that, the foregoing two examples of the use of resources "minimum width" qualifier, sw <N> dp, which specifies the minimum value of both sides of the screen, regardless of the current orientation of the device. Therefore, sw <N> dp is simple to specify the layout of the entire screen size screen orientation by ignoring manner.

However, in some cases, it may be important how much the layout width or height is now available. For example, there are two side by side arrangement, each time the width of the screen provides at least 600dp use, whether the device is in the transverse or longitudinal direction. In this case, the resource looks like this:

res/layout/main_activity.xml        

res/layout-w600dp/main_activity.xml  

Note that the second set using the "available width" qualifier, w <N> dp. Thus, a device may use both layouts (if at least 600dp available width in the other direction than 600dp in one direction) depending on the direction of the screen.

If the available height is concerned, then the same can be used h <N> dp qualifier. Even using w <N> dp and h <N> dp qualifier binding.

Guess you like

Origin blog.csdn.net/IT_studied/article/details/89365311