Dev Guide/best practices/supporting multiple screens

Source: Internet
Author: User


Address: http://docs.huihoo.com/android/2.2/guide/practices/screens_support.html


This article is a bit outdated, and there should be the latest on the network.



Supports multiple screens

Android is designed to run on a variety of devices that provide screen sizes and resolutions. For applications, the platform provides consistent cross-device environment and handles many complex application UIS to adapt to display on the screen. At the same time, the open APIs of the platform allow application developers to precisely control the user interfaces of their applications when specific screen sizes and resolutions are displayed.

This document describes the support functions provided by the screen platform and how to use them in your application. The procedure described here allows you to easily create an application correctly displaying the screens of all supported devices. You can use it as a single deployment to anyAPK.

If you have developed and published apps for Android 1.5 or earlier, you should read this file and consider how you may need to adapt to your applications, provide correct display on different screens and new devices running Android 1.6 or higher. In most cases, only slight adjustments are necessary, but you need to ensure that your application is tested on all supported screens.

Starting from Android 2.2, this platform includes support for additional high-density displays.(Xhdpi ),Starting from Android 2.3, the platform includes support for additional largeScreen(Xlarge ). If you have followed the instructions in this document to support all other screen types, considerProvideXhdpiAndAdditional support for xlarge screens.

In particular, if you have an existing application that you want to provide on a small screen (such as qvga), or you want to provide better support for ultra-large screens, for how to provide more information, see the old application policy to do this.

Bytes ------------------------------------------------------------------------------------------------------------------------------

Screen support Overview

The following sections provide an overview of multi-screen support for the Android platform, including the terms and concepts used in the documentation and API, and a summary of screen configuration supported by the platform, an overview of API and underlying screen compatibility features.

Terms and concepts

Screen Size

The actual physical size is used to measure the diagonal line of the screen.

For simplicity, Android divides all physical dimensions into four broad sizes: small, normal, large, and extremely large. Applications can provide custom la s of these four sizes-platform transparent processing for rendering in physical size la S.

Aspect Ratio

The relationship between the physical width and height of the screen. Applications can provide layout resources with specific aspect ratios.longQualifierslongAnd notlong.

Resolution

The total number of physical pixels on the screen. Note that although the resolution is usuallyX in widthHigh, but the resolution does not provide a special aspect ratio. In Android, the application does not work on resolution.

Density

Based on the screen resolution, the pixels in the width and height of the physical screen spread. Screens with lower density have a relatively small spread, while screens with higher density have a high spread, sometimes significant-pixel propagation in the same area. Because, when other conditions are the same, the height and width of a UI element (such as a button) are defined as screen pixels. in low density, the display is very large, while the high density is very small.

For simplicity, Android divides the screen density into four types: low density, medium density, large density, and super large density. Applications can provide custom resources of these density-the platform handles any necessary resources, scales up or down to meet specific screen density.

Density-independent pixels (DP)

Applications can use a virtual pixel unit to define their own UI and express the size and position in a density-independent manner.

Density-independent pixels are equivalent to a physical pixel on a 160 DPI screen, and the benchmark density of the Platform (as described later in this document ). During running, the platform transparently processes the scaling of any required DP units based on the actual screen density. It is easy to convert DP units to screen pixels:Pixels
= DPS * (density/160). For example, 1 DP is equivalent to 240 physical pixels on a 1.5 DPI screen. We strongly recommend that you use the DP unit to define the UI of the application and make sure that your user interface is displayed on different screens in an appropriate way.

Screen support range

Since Android 1.6, the platform supports multiple screen sizes and resolutions, reflecting the types and sizes of devices running on many new platforms. If the app you are developing runs on Android
1.6 or later, you can use the compatibility feature of the Android platform to ensure that the UI of your application is properly supported by the screen size and resolution range.

To simplify the developer's design of user interfaces for multiple devices and allow more devices to participate without affecting the application, the platform divides the actual supported screen sizes and resolution ranges:

  • Four values in a broad sense: small,Normal,Large, AndXlarge
  • Four General density:Ldpi (Low), Mdpi (Medium), Hdpi (High), andXhdpi (Extra High)

Note:xhdpiThe density category is in Android 2.2 (API Level 8 ).XlargeThe size category is in Android 2.3 (API level 9 ).

Applications can provide custom resources of any four broad sizes (mainly layout) and any four broad density resources (mainly image drawables ). The application does not need to work with the actual physical device screen size or density. During running, the platform processes and loads the correct size or density resources based on the general size or density of the current device screen, and adapts to the actual pixel map of the screen.

The size/density configuration in a broad sense is centered around a allocatedA normalSizeAndBenchmark configuration of the density mdpi (medium. T-Mobile G1 and similar devices on the hvga screen that are based on all applications (by definition) written for Android 1.5 or earlier,The size isNormalThe density is mdpi.

Each screen configuration in a broad sense spans a series of actual screen density and physical sizes. For example, this means that multiple devices use the normal screen size to provide a slightly different screen size or aspect ratio. Similarly, multiple devices useHdpiThe screen density will provide a slightly different pixel density. The Android platform abstracts these differences,
-An application can provide a user interface designed to be in a broad sense of size and density, and display the UI on the current device based on the actual characteristics of the system.

Figure 1Describe the actual screen density and general density and size configuration of the Android platform.

Although this platform allows your applications to provide custom configuration resources for various sizes and density, you do not need to write custom code or provide custom screen size and density for each combination of resources. The platform provides powerful compatibility. As described in the following sections, You can process most of the work of your application on the screen of any device and correctly execute the UI of your application. For more information about how to implement the UI correctly displayed on the device screen and platform version, seeBest practices for screen independence.

To help you test your application, the android SDK contains the simulator skin and copies the actual device screen size and density that your application may run. You can also modify the default size and density of the simulator appearance to any specific Screen Copy features.

Table 1The screen size and density of the simulator prototype, including in the android SDK.


Low Density (120 ),Ldpi  Medium Density (160 ),
 Mdpi
High density (240 ),Hdpi Extra High Density
(320 ),Xhdpi
SmallScreen Qvga (240x320)      
NormalScreen Wqvga400 (240x400)
Wqvga432 (240x432)
Hvga (320x480) Wvga800 (480x800)
Wvga854 (480X854)
 
LargeScreen   Wvga800 * (480x800)
Wvga854 * (480X854)
   
Extra LargeScreen        

* To simulate this configuration, 160 custom density is specified. In the created AVD, wvga800 or wvga854 skin is used.

Overview of high (hdpi), medium (mdpi), low (ldpi) in the Android system device available density screen logarithm, see the screen size and density dashboard.

How Android supports multiple screens

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.