Android interface design adapted to different screen sizes and density interpretations

Source: Internet
Author: User

Android is a device that runs on a variety of different screen sizes and densities. The Android system provides a unified development environment across devices and handles most of the work to adjust the screen of each application's user interface to display on it. At the same time, the system provides APIs that allow you to control the UI-specific screen size and density of your application to optimize your user interface design with different screen configurations. As designers, it is also important to maximize the user experience for all devices or to facilitate the use of reading, rather than simply stretching them to fit on-screen devices.

25 Academy Share with you the question of the size and density of different screens that the Android interface is designed to fit. There are several points of knowledge that need to be interpreted.

The first point of knowledge interpretation: Principle of 48DP law in appui design

For example, the pixels (px) of the buttons and pictures in the low-resolution, medium-resolution and high-resolution display, you can see that the physical size is changed.

In the look, using DP as the unit, the physical size has not changed much.

Anyway, the development of Android, the general will use DP to specify the size of a component. Of course, occasionally someone will use pixels (px) to specify the size of the component, may be a novice, or perhaps the person's program does not want to be compatible with more devices.

The above explains what DP,DP is a fundamentally device-independent unit that guarantees a set of UI adaptations on different machines, with no significant deviations from the display effect. What is the 48DP law?

In general, the 48DP is approximately 9 mm in size on the physical screen, while the recommended size of all touch-class controls in the UI design is between 7 and 10 millimeters, because between this value the control's point rate is greatly increased and visually comfortable.

So when your touch control's height and width is greater than or equal to 48DP, you can guarantee that your control will not be less than 7 mm on any device, while also ensuring that the content in the control looks comfortable and does not appear to be a false touch. This is the so-called 48DP law, of course, all this is a recommended value, the law in the heart, the actual situation of flexible processing, rather than being bound by the law, is a good appui designer.

It is also important to note that there are at least 8DP of white space between controls

For example, the size of the pencil picture control on the left is 48DP*48DP, the right button control has a height of 48DP, the width is 48*3DP, and the size fits perfectly with the 48DP law. The spacing between the picture and the button is 8DP, which guarantees the appropriate spacing between the picture and the button, the content of the button and the top edge of the button control is 4DP, so that if the two button controls are up and down together, the spacing between the two button contents is 8DP, thus guaranteeing its aesthetics. Content Center alignment and so on is not much to say, this is the most basic.

Second point of understanding: convert between DP and PX in Android

In the XML layout file, we can either set the PX or set the DP (or DIP). In general, we will choose to use DP, which will ensure that the layout of different screen resolutions on the machine is consistent. But in the code, how to deal with it? Many of the methods in the control provide only a method for setting PX, such as setpadding, and do not provide a way to set the DP. At this point, if you need to set the DP, it is necessary to convert the DP into PX.

Second point of understanding: How to make Android fit

The foundation of Android's multi-screen support is its ability to manage the layout of applications and to render objects in a manner that is rendered in an appropriate way to the current screen. The system handles most of the work that is scaled by the layout to fit the screen size/density and the scaled bitmap can be drawn on screen density to properly render your application configuration on each screen (if applicable). To better handle different screen configurations, however, you should also:

Explicitly declare a list of supported applications on the screen size application


By declaring its screen size application support, you can make sure that only devices that are supported by your screen can download your app. For different screen sizes, announcing support may also affect how the system attracts your application on a larger screen, specifically whether your application is running screen compatibility mode.
to declare the application support for screen size, you should include <supports-screens> elements in your manifest file.
provides different layouts, different screen sizes
By default, Android adjusts the layout of your application to fit the current device screen. In most cases, this works very well. In other cases, your user interface may not look good and may require different screen resizing. For example, on a larger screen, you may need to adjust the position and size of some elements to take advantage of additional screen space, or on a smaller screen, you may need to resize so everything fits on the screen.
Configuring qualifiers can you use it?? Provides granular resource-specific small, normal, large, and XLarge. For example, the layout of the oversized screen should be in layout-xlarge/.
with Android 3.2 (API level 13), the above dimension groups are deprecated and you should use the SW<N>DP configuration qualifier to define the minimum available width for your layout resources. For example, if your multi-pane tablet layout needs at least 600DP screen width, you should put it on layout-sw600dp/. Use new technology to declare resource layouts further discussion in the relevant section announcing the flat layout for Android 3.2.
a bitmap that is different for different screen densities can be plotted
by default, Android expands your drawing objects ' bitmaps (. png,. jpg, and. gif files) and nine patches (. 9.png files), Make them appear to be the corresponding physical dimensions on each device. For example, if your application only provides a bitmap for the baseline to be plotted, the medium density screen (MDPI), then the system expands up on the high-density screen when, and shrinks down to the low-density screen. This ratio can cause bitmaps of artifacts. To make sure your bitmap looks the best, you should include a different resolution of the alternate version at different screen densities. The
configures qualified persons to be used for density of specific resources ldpi (low), MDPI (Medium), hdpi (High), and xhdpi (Extra high). For example, a bitmap high-density screen should be in drawable-hdpi/.

Android interface design adaptable to different screen sizes and densities table interpretation

Screen Features Qualifying Description
Size small The resource is a small size screen.
normal The resource is a normal -sized screen. (This is the size of the baseline.) )
large The resource is a large -size screen.
xlarge Resources, large screen size.
Density ldpi Low density (ldpi) screen of resources (? 120DPI).
mdpi The resource for the medium density (MDPI) screen (? 160dpi). (This is the baseline density.) )
hdpi For the high-density (HDPI) screen of the resource (? 240DPI).
xhdpi Additional high density (xhdpi) screen resources (? 320dpi).
nodpi All the density of the resource. These are resources that are not related to density. The system cannot extend a resource labeled with this modifier, regardless of the current screen density.
tvdpi The resource screen mdpi and hdpi are between the two; About 213dpi. This is not considered a "primary" density group. It is mainly used for TVs and most applications do not need it, providing mdpi and hdpi resources sufficient to satisfy most applications, the system will extend them as appropriate. If you think it is necessary to provide tvdpi resources, you should adjust their size to a factor of 1.33 * mdpi. For example, a 100 pixel x 100 pixel image for the mdpi screen should be a 133px x 133px tvdpi.
Direction land The resource is in the landscape (widescreen) screen.
port The resource is in the portrait (aspect ratio) screen.
Aspect ratio long The resource has a significantly higher or larger aspect ratio (in portrait or landscape, respectively) screens than the baseline screen configuration.
notlong The aspect ratio that the resource has, similar to the screen used by the baseline screen configuration.

Android interface design adapted to different screen sizes and density interpretations

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.