Android UI adaption qualifier

Source: Internet
Author: User

Android UI adaption qualifier
Introduction

The application runs on Android machines of different sizes, causing additional overhead to the applicability of the UI. However, the occurrence of delimiters easily solves this problem. You can create a folder related to the delimiter to load resources.

Qualifier usage

The qualifier (mdpi, tvdpi, hdpi) helps us determine the screen density.
The land, port can help us differentiate the screen status.
Qualifier (en, fr ...) It can help us with our language and region
Qualifier (v3, v4 ...) This helps us differentiate the Android version.
Qualifier (1024x600 ...) Allows you to adapt to the screen of computing virtual keys or without computing virtual keys.
......

Android SDK Supporting Multiple Screens
Supporting Multiple Screens

Qualifier list
Features Qualifier Description
Screen Size Small
Normal
Large
Xlarge
Small: this screen is similar to a low-resolution QVGA screen. The minimum layout size for a small screen is approximately 320x0000dp. For example, QVGA low resolution and VGA high resolution.
Normal: this screen is similar to a medium-resolution HVGA screen. The minimum layout size for a normal screen is approximately 320x470dp. For example, WQVGA low-resolution screen, HVGA medium-resolution screen, and WVGA high-resolution screen.
Large: this screen is similar to a medium-resolution VGA screen. The minimum layout size for a large screen is approximately x DP. For example, VGA and WVGA moderate-resolution screens.
Xlarge: this screen is considered to be larger than the traditional medium-resolution HVGA screen. The minimum layout size for the xlarge screen is approximately x960dp. In most cases, this ultra-large screen device needs to be carried in a backpack because it is too large, and most likely is a tablet-style device.
Note: using the size qualifier does not mean that the resource is only used for the screen of this size. If no qualifier is provided to provide the optional resources that match the current device configuration, the system uses the resource closest to the configuration.
Warning if all the resources using the dimension qualifier are larger than the current screen, the system will not use them and the application will crash at runtime (for example, if all la s are marked with xlarge delimiters, the device is a normal-sized screen ).
This qualifier is added to Versions later than API Level 4.
Screen direction Port
Land
Port: vertical device (vertical)
Land: horizontal device (horizontal)
If the user rotates the screen, this limit can be changed during the application program running.
The orientation configuration field indicates the direction of the current device.
Screen pixel density (dpi) Ldpi
Mdpi
Hdpi
Xhdpi
Nodpi
Tvdpi
Ldpi: low-resolution screen with around DPI;
Mdpi: medium-resolution screens (on traditional HVGA) with around DPI );
Hdpi: high-resolution screen with around DPI;
Xhdpi: for ultra-high resolution screens of approximately DPI, it is added to Versions later than API base 8;
Nodpi: this limit is used for bitmap resources that do not want to scale based on the resolution of the matching device.
Tvdpi: the screen between the mdpi and hdpi, which is about 213 dpi. This type of grouping is not the main resolution, most of which is for TV, and most applications do not need it-providing mdpi and hdpi resources can meet the needs of most applications, and the system scales them properly. This qualifier is introduced after API Level 13.
The scaling ratio between the four major resolutions is: 3: 4: 6: 8 (ignore the tvdpi resolution), so a 9x9 ldpi bitmap, in mdpi, It is 12x12, 18x18 in hdpi, and 24x24 in xhdpi.
If you feel that the image resources on TV or some other devices are not good-looking and you want to try tvdpi resources, the scaling factor is 1.33 * mdpi. For example, an mdpi image of 100px x 100px should be scaled into a tvdpi image of 133px x 133px.
Note: using a resolution qualifier does not mean that the resource is only applicable to the screen with the corresponding resolution. If no available resource matches the current device configuration, the system uses the closest resource.
MCC and MNC Mcc310
Mcc310-mnc004
Mcc208-mnc00
And so on
MCC is The mobile country code, followed by a mobile network code (MNC: mobile network code) that selectively follows The SIM card from The device ). For example, in any carrier, mcc310 stands for the United States, mcc310-mnc004 stands for the United States's Venizon company, mcc208-mnc00 stands for the French Orange Company.
If the device uses an audio connection (GSM phone), the value of MCC and MNC comes from the SIM card.
MCC can also be used independently (for example, including legal resources in special countries in applications ). If you only need to specify the language environment, you can use the language and region qualifier instead (discussed later ). If you decide to use the MCC and MNC delimiters, You need to carefully test them so that they can meet your expectations.
You can also view the configuration domain mcc and mnc, which indicate the current mobile country code and mobile network Code respectively.
Mcc: http://developer.android.com/reference/android/content/res/Configuration.html
Mnc: http://developer.android.com/reference/android/content/res/Configuration.html
Language and region En
Fr
En-rUS
Fr-rFR
Fr-rCA
And so on
The language is defined with two letters of the ISO 639-1 language code, followed by two optional ISO-3166-1-appha-2 area code letters (front is lowercase "r ").
This encoding is case-insensitive. The r prefix is used to distinguish the region and cannot be specified separately.
If the user changes the language settings in the system, the corresponding language can also be changed during the running of the application.
Minimum Width sw dp
For example:
Sw320dp
Sw600dp
Sw720dp
And so on
The basic screen size refers to the shortest available area. Specifically, the minimum width of a device is the shortest width and height of the screen (or the minimum possible width of the screen ). In this way, you can use this qualifier to ensure that the application has at least dp The width of the UI, regardless of the current direction of the screen.
For example, if the layout requires a minimum screen size of at least 600dp at any time, you can use this qualifier to create layout Resources in the res/layout-sw600dp/directory. The system uses these resources only when the available screen size is at least 600dp, regardless of whether the 600dp is the height or width recognized by the user. The minimum width is the fixed screen size feature of the device. When the screen direction changes, the minimum width of the device does not change.
The minimum width of the device must consider the screen decoration and the occupation of the system UI. For example, if a device has some Fixed UI elements going along the axis of the smallest width and occupying a certain amount of screen space, the minimum width declared by the system is smaller than the actual screen size, because the pixels occupied by the system are invalid for the UI of the user application. Therefore, this value should be the minimum actual size required for the application layout (normally, this value is the minimum width supported by the layout regardless of the current direction of the screen ).
The following are some values of common screen sizes that can be used:
1.320. devices configured for the following screens:
240x320ldpi (QVGA handheld device)
320x480 mdpi (handheld device)
480x800 hdpi (High Resolution handheld device)
2.480, for X mdpi screen (tablet or handheld device)
3.600, for 600x1024mdip screens (7 inch fl)
4.720, for 10 inch x1280mdip screen (tablet)
When an application provides multiple resource directories with different minimum width qualifiers, the system uses the resource that is closest to (not exceeding) the minimum width of the device.
This qualifier is added to API Level 13.
For more information, see the android: requiresSmallestWidthDp attribute. It declares the minimum and minimum widths compatible with your application, and the smallestScreenWidthDp configuration field holds the value of the minimum width of the device.
Available width w dp
For example:
W720dp
W1024dp
And so on
Specify the minimum available screen width, which should be defined in the unit of dp in the resource. . When the direction changes between the horizontal and vertical directions, this configuration value will match the current actual width.
When the application provides multiple resource directories with different values for this configuration, the system uses the configuration closest to (not exceeding) The current screen width of the device. This value must take into account the space occupied by the screen decoration. Therefore, if the device has some Fixed UI elements on the left or right side of the display, the width is smaller than the actual screen size, because of the occupation of these Fixed UI elements, the available space of the application is reduced.
This feature is added to API Level 13 and also looks at the screenWidthDp configuration field, which holds the current screen width.
Available height h dp
For example:
201720dp
H1024dp
And so on
Specify the minimum available screen height. The value should be defined in the unit of dp in the resource. When the direction is changed either horizontally or vertically, the configuration value should match the current actual height.
When the application provides multiple resource directories with different values for this configuration, the system uses the configuration closest to (not exceeding) The current screen height of the device. Therefore, if a device has Fixed UI elements at the top or bottom of the display, the height is smaller than the actual screen size, because of the occupation of these Fixed UI elements, the available space of the application is reduced. Unfixed screen Decoration (for example, the phone status bar can be hidden in full screen) is not considered, and window decoration such as the title bar or operation bar is not considered, therefore, the application must be prepared to process less space than they specify.
This qualifier is added to API Level 13.
The screenHeightDp configuration field holds the height of the current screen.
Screen appearance Long
Notlong
Long: long screen, such as WQVGA, WVGA, FWVGA
Notlong: Non-long screen, such as QVGA, HVGA, VGA
This qualifier is added to Versions later than API Level 4.
This qualifier is completely based on the screen appearance ratio, not relative to the screen direction.
Check the screenLayout configuration field, which indicates whether the screen is a long screen.
Berth Mode Car
Desk
Car: the device stops in the car.
Desk: the device stops at the desk.
This qualifier is added to Versions later than API level 8. If the user changes the location where the device is docked, the limitation can be changed during the running of the application. You can use the UiModeManager object to enable or disable this mode.
Night mode Night
Notnight
Night: night
Notnight: daytime
Added to Versions later than API level 8. If the night mode is retained in automatic mode (default, the pattern is changed based on the daytime time. You can use the UiModeManager object to enable or disable this mode.
Touch screen type Notouch
Stylus
Finger
Notouch: Non-touch screen device
Stylus: resistance screen devices for pen
Finger: Touch Screen Device
The touchscreen configuration field indicates the touch screen type on the device.
Keyboard availability Keysexposed
Keyshidden
Keyssoft
Keysexposed: the device has an available keyboard. If the keyboard is enabled, you can use this qualifier even if the keyboard is not exposed to users. If no keypad is provided or disabled, you can use this qualifier only when the keypad is exposed to users.
Keyshidden: the device has an available hard keyboard, but it is hidden and there is no available soft keyboard.
Keyssoft: the device has an available keyboard, whether visible or not.
If you provide keysexposed resources but do not have keyssoft resources, the system uses keysexposed resources no matter whether the keyboard is visible as long as the system has an available soft keyboard.
If you enable the hard keyboard, you can change this limitation during the application running.
The hardKeyboardHidden and keyboardHidden configuration fields indicate the visibility of the hard keyboard and the visible keyboard type (including the soft keyboard ).
Main text input method Nokeys
Qwerty
L2key
Nokeys: The device does not have a hard keyboard for text input;
Qwerty: the device has a standard hard keyboard, whether visible or not;
12 key: the device has 12 keys, regardless of whether the user is visible.
The keyboard configuration field specifies the available main text input methods.
Validity of the navigation key Navexposed
Navhidden
Navexposed: the navigation key is available to users;
Navhidden: the navigation key is unavailable.
If you can see the navigation key, you can change this restriction when the application is running.
The navigationHidden configuration field indicates whether the navigation key is hidden.
Main non-touch screen navigation methods Nonav
Dpad
Trackball
Wheel
Nonav: the device has no navigation facilities except touch screens.
Dpad: the device has a d-pad for navigation ).
Trackball: the device has a trackball for navigation.
Wheel: the device has a navigation wheel (uncommon ).
Navigation
The configuration field specifies the available navigation method type.
Platform version (API level) For example:
V3
V4
V7
And so on
API level supported by the device. For example, v1 indicates API Level 1 (devices with Android1.0 or higher) and v4 indicates API level 4 (devices with Android1.6 or higher)
Warning Android1.5 and 1.6 can match resources only when the qualifier matches the platform version.
Qualifier example

You only need to apply a qualifier to the dash,Xx-qualifier

Qualifier execution sequence

The delimiter matches downward, from high to low.

Related Article

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.