android系统资源更换-语言切换或配置改变

来源:互联网 发布:淘宝商品文案编辑兼职 编辑:程序博客网 时间:2024/06/05 12:07

QVGA使用ldpi,虽然有不同尺寸,但都是120dpi左右;HVGA同理;如下图;




-finger    用于触摸屏的设备

-hdpi    近似于240dpi的高级显示密度的屏幕

-mdpi    近似于160dpi的中级显示密度的屏幕

-ldpi    近似于120dpi的低级显示密度的屏幕

-land    横屏显示

-port    竖屏显示

-long    比较长的屏幕,例如WQVGA(432×240), WVGA(800×480), FWVGA(854×480)


图片缩放比列为 3 :4:6:8   ldpi,mdpi,hdip,xhdip

具体计算方法为:

  ( (size * tdensity) + (sdensity >> 1) ) / sdensity;

size:长/宽
sdensity:原图密度;
tdensity:终端密度;

drawable-en:英文设置下的图片资料,drawable-zh中文设置下的图片资料。
若是要为不合像素的手机筹办的话,须要(以drawable-en为例申明)
:drawable-en-hdpi
:drawable-en-ldpi
:drawable-en-mdpi
同理:为美式英语,
:drawable-en-rUS-hdpi
:drawable-en-rUS-ldpi
:drawable-en-rUS-mdpi
再错杂一点,为不合标的目标的筹办图片资料
//竖直
:drawable-en-rUS-port-hdpi
:drawable-en-rUS-port-ldpi
:drawable-en-rUS-port-mdpi
//横屏
:drawable-en-rUS-land-hdpi
:drawable-en-rUS-land-ldpi
:drawable-en-rUS-land-mdpi


建树这些文件夹是有次序的。即按优先级别分列的,见下表。所以建树文件夹时一般从左到右的分列其优先级别如:drawable-en-rUS-land-mdpi
如:drawable-en-rUS-port-160dpi-finger-qwerty-dpad-480 x320/


限制符Qualifier

值Values

移动国度码MCC和移动收集码MNC

手机设备SIM卡上的移动国度码和移动收集码。比如mcc310-mnc004 美国,Verizon品牌); mcc208-mnc00 法国,Orange品牌); mcc234-mnc00 英国,BT品牌). 
若是这个设备应用一个无线连接(GSM德律风),则MCC来自SIM卡,而MNC来自该设备将要附着的收集。你有时会仅应用MCC,例如包含特定国度合法资料在您的应用法度中。若是您的应用法度指定了MCC/MNC组合的资料,这些资料仅在MCCMNC都匹配的时辰才干应用。

说话和区域Languageand region

两个字母的ISO639-1说话码和ISO3166-1-alpha-2区域码 "r"为前缀。比如en-rUS,fr-rFR,es-rES.这个代码是大小写敏感的:说话码是小写字母,国度码是大写字母。你不克不及零丁指定一个区域,然则你可以零丁指定一个说话,比如en,fr, es, zh.

屏幕标的目标Screenorientation

纵向,横向,正方形(port,land, square

屏幕像素密度Screenpixel density

92dpi,108dpiAndroid选择应用哪个资料时,它对屏幕像素密度的处理惩罚和其它限制符不合。在文章后面描述的步调1Android如何查找最匹配的目次中,屏幕密度总被认为是匹配的。在步调4中,若是被推敲的限制符是屏幕密度,Android将选择在那个地位的最佳匹配,而无需持续步调5

触摸屏类型Touchscreentype

非触摸式,触摸笔,手指(notouch,stylus, finger

键盘可用体式格式Whetherthe keyboard is available to the user

外在键盘,隐躲键盘,软键盘(keysexposed,keyshidden,keyssoft
若是你的应用法度有一个特定的资料只能经由过程软件盘应用,则应用keyssoft 值,若是没有keyssoft 资料可用(只有keysexposed  keyshidden)并且该设备显示了一个软键盘,那么体系将应用keysexposed 资料。

首选文本输进办法Primarytext input method

不支撑按键标准键盘,12(nokeys,qwerty, 12key)

首选非触摸式导航办法Primarynon-touchscreen
navigation method

不支撑导航滑板跟踪球滚轮(nonav,dpad, trackball, wheel)

屏幕辨别率Screendimensions

320 x240,640 x480, 更大的辨别率必须先被指定。

SDK版本SDKversion

设备支撑的SDK版本,比如v3Android1.0SDKv11.1SDKv21.5SDKv3

小版本(Minorversion)

你今朝还不克不及指定小版本,它老是被设置为0



表2.配置限定符名称
 


Alternate Resources (for alternate languages and configurations)

You can supply different resources for your application to use depending on the UI language or hardware configuration on the device. Note that although you can include different string, layout, and other resources, the SDK does not expose methods to let you specify which alternate resource set to load. Android detects the proper set for the hardware and location, and loads them as appropriate. Users can select alternate language settings using the settings panel on the device.

To include alternate resources, create parallel resource folders with qualifiers appended to the folder names, indicating the configuration it applies to (language, screen orientation, and so on). For example, here is a project that holds one string resource file for English, and another for French:

MyApp/ 
    res/ 
        values-en/ 
            strings.xml 
        values-fr/ 
            strings.xml

Android supports several types of qualifiers, with various values for each. Append these to the end of the resource folder name, separated by dashes. You can add multiple qualifiers to each folder name, but they must appear in the order they are listed here. For example, a folder containing drawable resources for a fully specified configuration would look like this:

MyApp/ 
    res/ 
        drawable-en-rUS-large-long-port-mdpi-finger-keysexposed-qwerty-navexposed-dpad-480x320/

More typically, you will only specify a few specific configuration options. You may drop any of the values from the complete list, as long as the remaining values are still in the same order:

MyApp/ 
    res/ 
        drawable-en-rUS-finger/ 
        drawable-port/ 
        drawable-port-mdpi/ 
        drawable-qwerty/

Table 2 lists the valid folder-name qualifiers, in order of precedence. Qualifiers that are listed higher in the table take precedence over those listed lower, as described in

Table 2

QualifierValuesMCC and MNC

The mobile country code optionally followed by mobile network code from the SIM in the device. For example mcc310 (U.S. on any carrier); mcc310-mnc004 (U.S., Verizon brand);mcc208-mnc00 (France, Orange brand); mcc234-mnc00 (U.K., BT brand).

If the device uses a radio connection (GSM phone), the MCC will come from the SIM, and the MNC will come from the network to which the device is attached. You might sometimes use the MCC alone, for example to include country-specific legal resources in your application. If your application specifies resources for a MCC/MNC combination, those resources can only be used if both the MCC and the MNC match.

Language and region

The two letter ISO 639-1 language code optionally followed by a two letter ISO 3166-1-alpha-2 region code (preceded by lowercase "r"). For example fren-rUSfr-rFRes-rES.

The codes are not case-sensitive; the r prefix is used to distinguish the region portion. You cannot specify a region alone, but you can specify a language alone, for example en,fres.

Screen dimensions

smallnormallarge

Specify that the resource is for a particular class of screen. The meanings of these are:

  • Normal screens are based on the traditional Android HVGA medium density screen. A screen is considered to be normal if it is at least this size (independent of density) and not large. Examples of such screens a WQVGA low density, HVGA medium density, WVGA high density.
  • Small screens are based on the space available on a QVGA low density screen. Considering a portrait HVGA display, this has the same available width but less height -- it is 3:4 vs. HVGA's 2:3 aspect ratio. Examples are QVGA low density and VGA high density.
  • Large screens are based on the space available on a VGA medium density screen. Such a screen has significantly more available space in both width and height than an HVGA display. Examples are VGA and WVGA medium density screens.
Wider/taller screens

longnotlong

Specify that the resource is for a taller/wider than traditional screen. This is based purely on the aspect ration of the screen: QVGA, HVGA, and VGA are notlong; WQVGA, WVGA, FWVGA are long. Note that long may mean either wide or tall, depending on the current orientation.

Screen orientation

portlandsquare

Specifies that the resource is for a screen that is tall (port) or wide (land); square is not currently used.

Screen pixel density

ldpimdpihdpinodpi

Specifies the screen density the resource is defined for. The medium density of traditional HVGA screens (mdpi) is defined to be approximately 160dpi; low density (ldpi) is 120, and high density (hdpi) is 240. There is thus a 4:3 scaling factor between each density, so a 9x9 bitmap in ldpi would be 12x12 is mdpi and 16x16 in hdpi. The special nodpi density can be used with bitmap resources to prevent them from being scaled at load time to match the device density.

When Android selects which resource files to use, it handles screen density differently than the other qualifiers. In step 1 of How Android finds the best matching directory(below), screen density is always considered to be a match. In step 4, if the qualifier being considered is screen density, Android will select the best final match at that point, without any need to move on to step 5.

You can also specify explicit densities like 92dpi or 108dpi, but these are not fully supported by the system so should not be used.

Touchscreen typenotouchstylusfingerWhether the keyboard is available to the user

keysexposedkeyshiddenkeyssoft

If your application has specific resources that should only be used with a soft keyboard, use the keyssoft value. If no keyssoft resources are available (only keysexposed andkeyshidden) and the device shows a soft keyboard, the system will use keysexposedresources.

Primary text input methodnokeysqwerty12keyWhether the navigation keys are available to the user

navexposednavhidden

If the hardware's navigation keys are currently available to the user, the navexposed resources will be used; if they are not available (such as behind a closed lid), navhidden will be used.

Primary non-touchscreen
navigation methodnonavdpadtrackballwheelScreen dimensions320x240640x480, etc. The larger dimension must be specified first. This configuration is deprecated and should not be used; use instead screen dimension, wider/taller screens, and screen orientation described above.SDK versionThe SDK version supported by the device, for example v3. The Android 1.0 SDK is v1,the 1.1 SDK is v2, and the 1.5 SDK is v3.(Minor version)(You cannot currently specify minor version. It is always set to 0.)

This list does not include device-specific parameters such as carrier, branding, device/hardware, or manufacturer. Everything that an application needs to know about the device that it is running on is encoded via the resource qualifiers in the table above.

All resource directories, qualified and unqualified, live under the res/ folder. Here are some guidelines on qualified resource directory names:

  • You can specify multiple qualifiers, separated by dashes. For example, drawable-en-rUS-land will apply to US-English devices in landscape orientation.
  • The qualifiers must be in the order listed in Table 2 above. For example:
    • Correct: values-mcc460-nokeys/
    • Incorrect: values-nokeys-mcc460/
  • Values are case-insensitive. The resource compiler converts folder names to lower case before processing to avoid problems in case-insensitive file systems. On case-sensitive file systems, you should keep all names lower-case or at least use a consistent case to protect your future sanity when trying to find a resource file.
  • Only one value for each qualifier type is supported. For example, if you want to use exactly the same drawable files for Spain and France, you will need two resource directories, such asdrawable-rES/ and drawable-rFR/, containing identical files. You cannot have a directory nameddrawable-rES-rFR/.
  • Qualified directories cannot be nested. For example, you cannot have res/drawable/drawable-en.

How resources are referenced in code

All resources will be referenced in code or resource reference syntax by their simple, undecorated names. So if a resource were named this:
      MyApp/res/drawable-port-mdpi/myimage.png
It would be referenced as this:
      R.drawable.myimage (code)
      @drawable/myimage (XML)

If several drawable directories are available, Android will select one of them (as described below) and load myimage.png from it.

How Android finds the best matching directory

Android will pick which of the various underlying resource files should be used at runtime, depending on the current configuration of the device. The example used here assumes the following device configuration:

Locale = en-GB
Screen orientation = port
Screen pixel density = mdpi
Touchscreen type = notouch
Primary text input method = 12key

Here is how Android makes the selection:

  1. Eliminate resource files that contradict the device configuration. For example, assume that the following resource directories are available for drawables. The drawable-fr-rCA/ directory will be eliminated, because it contradicts the locale of the device.
    MyApp/res/drawable/ 
    MyApp/res/drawable-en/ 
    MyApp/res/drawable-fr-rCA/ 
    MyApp/res/drawable-en-port/ 
    MyApp/res/drawable-en-notouch-12key/ 
    MyApp/res/drawable-port-ldpi/ 
    MyApp/res/drawable-port-notouch-12keyException: Screen pixel density is the one qualifier that is not used to eliminate files. Even though the screen density of the device is medium dpi, drawable-port-ldpi/ is not eliminated from the list, because every screen density is considered to be a match at this point.
  2. From Table 2, pick the highest-precedence qualifier that remains in the list. (Start with MCC, then move down through the list.)
  3. Do any of the available resource directories include this qualifier?
    • If No, return to step 2 and look at the next qualifier listed in Table 2. In our example, the answer is "no" until we reach Language.
    • If Yes, move on to step 4.
  4. Eliminate resource directories that do not include this qualifier. In our example, we eliminate all the directories that do not include a language qualifier.MyApp/res/drawable/ 
    MyApp/res/drawable-en/ 
    MyApp/res/drawable-en-port/ 
    MyApp/res/drawable-en-notouch-12key/ 
    MyApp/res/drawable-port-ldpi/ 
    MyApp/res/drawable-port-notouch-12key
    Exception: If the qualifier in question is screen pixel density, Android will select the option that most closely matches the device, and the selection process will be complete. In general, Android will prefer scaling down a larger original image to scaling up a smaller original image.

  5. Go back and repeat steps 2, 3, and 4 until only one choice remains. In the example, screen orientation is the next qualifier in the table for which we have any matches. Eliminate resources that do not specify a screen orientation.MyApp/res/drawable-en/ 
    MyApp/res/drawable-en-port/ 
    MyApp/res/drawable-en-notouch-12key/Only one choice remains, so that's it. When drawables are called for in this example application, the Android system will load resources from the MyApp/res/drawable-en-port/ directory. In addition, if the resource being loaded is a bitmap, it will be scaled up so that its supplied low density matches the device's medium density.

Tip: The precedence of the qualifiers is more important than the number of qualifiers that exactly match the device. For example, in step 4 above, the last choice on the list includes three qualifiers that exactly match the device (orientation, touchscreen type, and input method), while drawable-en has only one parameter that matches (language). However, language has a higher precedence, so drawable-port-notouch-12key is out.

This flowchart summarizes how Android selects resource directories to load.


Terminology

The resource system brings a number of different pieces together to form the final complete resource functionality. To help understand the overall system, here are some brief definitions of the core concepts and components you will encounter in using it:

Asset: A single blob of data associated with an application. This includes object files compiled from the Java source code, graphics (such as PNG images), XML files, etc. These files are organized in a directory hierarchy that, during final packaging of the application, is bundled together into a single ZIP file.

aapt: Android Asset Packaging Tool. The tool that generates the final ZIP file of application assets. In addition to collecting raw assets together, it also parses resource definitions into binary asset data.

Resource Table: A special asset that aapt generates for you, describing all of the resources contained in an application/package. This file is accessed for you by the Resources class; it is not touched directly by applications.

Resource: An entry in the Resource Table describing a single named value. Broadly, there are two types of resources: primitives and bags.

Resource Identifier: In the Resource Table all resources are identified by a unique integer number. In source code (resource descriptions, XML files, Java source code) you can use symbolic names that stand as constants for the actual resource identifier integer.

Primitive Resource: All primitive resources can be written as a simple string, using formatting to describe a variety of primitive types included in the resource system: integers, colors, strings, references to other resources, etc. Complex resources, such as bitmaps and XML describes, are stored as a primitive string resource whose value is the path of the underlying Asset holding its actual data.

Bag Resource: A special kind of resource entry that, instead of a simple string, holds an arbitrary list of name/value pairs. Each name is itself a resource identifier, and each value can hold the same kinds of string formatted data as a normal resource. Bags also support inheritance: a bag can inherit the values from another bag, selectively replacing or extending them to generate its own contents.

Kind: The resource kind is a way to organize resource identifiers for various purposes. For example, drawable resources are used to instantiate Drawable objects, so their data is a primitive resource containing either a color constant or string path to a bitmap or XML asset. Other common resource kinds are string (localized string primitives), color (color primitives), layout (a string path to an XML asset describing a view layout), and style (a bag resource describing user interface attributes). There is also a standard "attr" resource kind, which defines the resource identifiers to be used for naming bag items and XML attributes

Style: The name of the resource kind containing bags that are used to supply a set of user interface attributes. For example, a TextView class may be given a style resource that defines its text size, color, and alignment. In a layout XML file, you associate a style with a bag using the "style" attribute, whose value is the name of the style resource.

Style Class: Specifies a related set of attribute resources. This data is not placed in the resource table itself, but used to generate constants in the source code that make it easier for you to retrieve values out of a style resource and/or XML tag's attributes. For example, the Android platform defines a "View" style class that contains all of the standard view attributes: padding, visibility, background, etc.; when View is inflated it uses this style class to retrieve those values from the XML file (at which point style and theme information is applied as approriate) and load them into its instance.

Configuration: For any particular resource identifier, there may be multiple different available values depending on the current configuration. The configuration includes the locale (language and country), screen orientation, etc. The current configuration is used to select which resource values are in effect when the resource table is loaded.

Theme: A standard style resource that supplies global attribute values for a particular context. For example, when writing an Activity the application developer can select a standard theme to use, such as the Theme.White or Theme.Black styles; this style supplies information such as the screen background image/color, default text color, button style, text editor style, text size, etc. When inflating a layout resource, most values for widgets (the text color, selector, background) if not explicitly set will come from the current theme; style and attribute values supplied in the layout can also assign their value from explicitly named values in the theme attributes if desired.

Overlay: A resource table that does not define a new set of resources, but instead replaces the values of resources that are in another resource table. Like a configuration, this is applied at load time to the resource data; it can add new configuration values (for example strings in a new locale), replace existing values (for example change the standard white background image to a "Hello Kitty" background image), and modify resource bags (for example change the font size of the Theme.White style to have an 18 pt font size). This is the facility that allows the user to select between different global appearances of their device, or download files with new appearances.




 

配置限定符值说明MCC和MNC例如:
mcc310
mcc310-mnc004
mcc208-mnc00
等MCC是移动国家代码的英文首字母缩写(The mobile country code),它的后面可选择性的跟随来自设备内的SIM卡的移动网络代码(MNC:mobile network code)。如在任何载体上,mcc310代表美国,mcc310-mnc004代表美国的Venizon公司,mcc208-mnc00代表法国的Orange公司。
如果设备使用音频连接(GSM 电话),那么MCC和MNC的值来自SIM卡。
也可以单独使用MCC(例如,在应用程序中包含特殊国家合法的资源)。如果仅需要指定语言环境,那么可以使用language和region限定符来替代(稍后讨论)。如果决定要使用MCC和MNC限定符,就要仔细测试,使它能够满足你所期望的工作。
还可以查看配置域mcc和mnc,它们分别指示了当前的移动国家代码和移动网络代码。
mcc:http://developer.android.com/reference/android/content/res/Configuration.html#mcc
mnc:http://developer.android.com/reference/android/content/res/Configuration.html#mnc
 语言和地区例如:
en
fr
en-rUS
fr-rFR
fr-rCA语言是用两个字母的ISO 639-1语言代码定义的,紧跟其后的是可选的两个ISO-3166-1-appha-2地区代码字母(前面是小写的“r”)。
这个编码不区分大小写,r前缀被用于区分地区部分,不能够单独指定地区。
如果用户改变了系统中的语言设置,那么在应用程序的运行期间也能够改变为对应的语言。最小宽度sw<N>dp
例如:
sw320dp
sw600dp
sw720dp
等屏幕的基本尺寸,是指最短的可用屏幕区域。具体的说,设备的最小宽度是屏幕可用的宽度和高度中最短的那个(也可以把它看做是屏幕的最小可能的宽度)。这样就可以使用这个限定符来确保应用程序至少有<N>dp的宽度可用于UI界面,而不管屏幕的当前方向。
例如,如果布局在任何时候都需要至少600dp的最小屏幕尺寸,那么就能够使用这个限定符,在res/layout-sw600dp/目录中创建布局资源。系统只会在可用屏幕的尺寸至少是600dp的时候才会使用这些资源,而不管600dp是否是被用户认知的高度或宽度。最小宽度是设备的固定屏幕尺寸特征,当屏幕的方向发生改变时,设备的最小宽度不改变。
设备的最小宽度需要考虑屏幕的装饰和系统UI的占用。例如,如果设备有一些固定的UI元素要沿着最小宽度的轴向,占用一定的屏幕空间,那么系统声明的最小宽度要比实际的屏幕尺寸要小,因为被系统占用的像素部分对用户应用程序的UI无效。因此,这个值应该是应用程序布局所需要的最小的实际尺寸(通常,这个值是布局支持的最小宽度,而不管屏幕的当前方向)。
以下是可以使用的通用屏幕尺寸的一些值:
1.320,针对以下屏幕配置的设备:
  240x320ldpi(QVGA手持设备)
  320x480mdpi(手持设备)
  480x800hdpi(高分辨率手持设备)
2.480,针对480x800mdpi的屏幕(平板或手持设备)
3.600,针对600x1024mdip的屏幕(7英寸平板)
4.720,针对720x1280mdip的屏幕(10英寸平板)
当应用程序提供了多个带有不同值的最小宽度限定符资源目录时,系统会使用最接近(不超出)设备最小宽度的那个资源。
这个限定符被添加在API级别13中。
还要看android:requiresSmallestWidthDp属性,它声明了与你的应用程序兼容的最小的最小宽度,并且smallestScreenWidthDp配置字段会持有这个设备最小宽度的值。可用宽度w<N>dp
例如:
w720dp
w1024dp
等指定最小的可用屏幕宽度,在资源中应该以dp为单位来定义<N>的值。当方向在横向和纵向之间改变时,这个配置值会跟当前的实际的宽度相匹配。
当应用程序给这个配置提供了多个不同值的资源目录时,系统会使用最接近(不超过)设备当前屏幕宽度的那个配置。这个值需要考虑屏幕装饰占据的空间,因此,如果设备在显示的左边或右边有一些固定的UI元素,那么使用的宽度值就要比实际的屏幕尺寸小,因为这些固定UI元素的占用,使得应用程序的可用空间减少。
这个特性被添加在API级别13中
还要看screenWidthDp配置字段,它持有当前的屏幕宽度。可用高度h<N>dp
例如:
h720dp
h1024dp
等指定最小的可用屏幕高度,在资源中应该以dp为单位来定义<N>的值,当方向在横向和纵向直接改变时,这个配置值应该跟当前的实际高度匹配。
当应用程序给这个配置提供了不同值的多个资源目录时,系统会使用最接近(不超过)设备当前屏幕高度的那个配置。这个要考虑屏幕装饰的占用情况,因此,如果设备在显示的上方或底部有一些固定的UI元素,那么要使用的高度值要比实际的屏幕尺寸小,因为这些固定UI元素的占用,使得应用程序的可用空间减少。不固定的屏幕装饰(如电话的状态栏能够在全屏时被隐藏)是不考虑的,像标题栏或操作栏这样的窗口装饰也不考虑,因此应用必须准备处理比它们指定的空间要小的情况。
这个限定符被添加在API级别13中。
还要看screenHeightDp配置字段,它持有当前屏幕的高度。屏幕尺寸small
normal
large
xlargesmall:这种屏类似低分辨率的QVGA屏幕。对于小屏的最小布局尺寸大约是320x426dp。例如QVGA低分辨率和VGA高分辨率。
normal:这种屏类似中等分辨率的HVGA屏幕。对于普通屏幕的最小布局尺寸大约是320x470dp。如,WQVGA低分辨率屏、HVGA中等分辨率屏、WVGA高分辨率屏。
large:这种屏类似中等分辨率的VGA屏幕,对于大屏幕的最小布局尺寸大约是480x640dp。例如VGA和WVGA的中等分辨率屏。
xlarge:这种屏被认为比传统的中等分辨率的HVGA屏幕大。针对xlarge屏的最小布局尺寸大约是720x960dp。在大多数情况下,这种超大屏幕的设备因为太大而要放到背包中来携带,而且最有可能的是平板样式的设备。
注意:使用尺寸限定符不意味着资源仅用于这个尺寸的屏幕。如果没有用限定符提供与当前设备配置相匹配的可选资源,那么系统会使用与配置最接近的资源。
警告:如果所有使用尺寸限定符的资源都比当前屏幕大,那么系统将不会使用它们,并且应用程序会在运行时崩溃(例如,如果所有的布局都被标记了xlarge限定符,而设备却是一个普通尺寸的屏幕)。
这个限定符被添加在API级别4以后的版本中。屏幕外观long
notlonglong:长屏幕,如WQVGA、WVGA、FWVGA
notlong:非长屏幕,如QVGA、HVGA、VGA
这个限定符被添加在API级别4以后的版本中
这个限定符完全是基于屏幕的外观比率,不相对屏幕的方向。
还要看screenLayout配置字段,它指示了屏幕是否是长屏。屏幕方向port
landport:纵向设备(垂直)
land:横向设备(水平)
如果用户旋转屏幕,这个限定能够在应用程序运行期间改变。
orientation配置字段指示当前设备的方向。泊位模式car
deskcar:设备停靠在汽车中
desk:设备停靠在书桌中
这个限定符被添加在API级别8以后的版本中
如果用户改变了设备的停靠地点,那么能够在应用程序的运行期间改变这个限定。可以使用UiModeManager对象来启用或禁止这种模式。夜间模式night
notnightnight:夜间
notnight:白天
被添加在API级别8以后的版本中
如果夜间模式被保留在自动模式中(默认),那么在应用程序运行期间,会基于白天的时间来进行模式的改变。可以使用UiModeManager对象来启用或禁止这种模式。屏幕像素密度(dpi)ldpi
mdpi
hdpi
xhdpi
nodpi
tvdpildpi:针对大约120dpi的低分辨率屏幕;
mdpi:针对大约160dpi的中等分辨率屏幕(在传统的HVGA上);
hdpi:针对大约240dpi的高分辨率屏幕;
xhdpi:针对大约320dpi的超高分辨率屏幕,被添加在API基本8以后的版本中;
nodpi:这个限定被用于不想根据匹配的设备分辨率进行缩放的位图资源。
tvdpi:在mdpi和hdpi之间的屏幕,大约是213dpi。这种分组不是主要的分辨率,大多数是为电视来考虑的,并且大多数应用不需要它---提供mdpi和hdpi资源就可以满足大多数应用程序需要了,并且系统会适当的缩放它们。这个限定符在API级别13以后被引入。
四种主要的分辨率之间的缩放比例是:3:4:6:8(忽略tvdpi分辨率),因此一个9x9的ldpi位图,在mdpi中是12x12、在hdpi中是18x18、在xhdpi中是24x24。
如果感觉在电视或其他某些设备上的图片资源不好看,并且想要试用tvdpi资源,那么缩放因子是1.33*mdpi。例如,一个100px x 100px的mdpi图片的图片应该被放大成133px x 133px的tvdpi图片。
注意:使用分辨率限定符不意味着资源仅适用与对应分辨率的屏幕。如果没有提供与当前设备配置匹配的可选资源,那么系统会使用最接近的资源。触屏类型notouch
stylus
fingernotouch:非触屏设备
stylus:有适用手写笔的电阻屏设备
finger:触屏设备
touchscreen配置字段,指示到了设备上的触屏类型。键盘可用性keysexposed
keyshidden
keyssoftkeysexposed:设备有可用的键盘。如果设备启用了软键盘,那么即使在硬键盘没有暴露给用户时也可以使用这个限定符。如果没有提供软键盘或者软键盘被禁用,那么只有在硬键盘被暴露给用户时才能够使用这个限定符。
keyshidden:设备有可用的硬键盘,但是被隐藏了,并且设备没有可用的软键盘。
keyssoft:设备有可用的软键盘,不管它是否可见。
如果提供了keysexposed资源,但没有keyssoft资源,那么只要系统有可用的软键盘,系统就会使用keysexposed资源而不管键盘是否可见。
如果用户打开了硬键盘,就可以在应用程序运行期间改变这个限定。
hardKeyboardHidden和keyboardHidden配置字段分别指明硬键盘的可见性以及可见的键盘类型(包括软键盘)。主要文本输入法nokeys
qwerty
l2keynokeys:设备没有用于文本输入的硬键盘;
qwerty:设备有标准的硬键盘,不管用户是否可见;
12key:设备有12个键的硬键盘,不管用户是否可见。
keyboard配置字段指明可用的主要文本输入方法。导航键的有效性navexposed
navhiddennavexposed:导航键对用户可用;
navhidden:导航键不可用。
如果用户能够看到导航键,那么在应用程序运行时就能够改变这个限定。
navigationHidden配置字段,指示导航键是否隐藏。主要的非触屏导航方法nonav
dpad
trackball
wheelnonav:除了使用触屏以外,设备没有其他导航设施。
dpad:设备有用于导航的定向板(d-pad)。
trackball:设备有用于导航的轨迹球。
wheel:设备有用于导航的定向滚轮(不常见)。
navigation配置字段指明可用的导航方法类型。平台版本(API 级别)例如:
v3
v4
v7
等设备支持的API级别。如v1代表API级别1(带有Android1.0或更高版的设备),v4代表API级别4(带有Android1.6或更高版本的设备)
警告:Android1.5和1.6只有在限定符跟平台版本完全匹配时,才能匹配资源
原创粉丝点击