不同的命名代表什么含义呢?详细见下表:
限定符Qualifier | 值Values |
移动国家码MCC和移动网络码MNC | 手机设备SIM卡上的移动国家码和移动网络码。比如mcc310-mnc004 (美国,Verizon品牌); mcc208-mnc00 (法国,Orange品牌); mcc234-mnc00 (英国,BT品牌). |
语言和区域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,108dpi等. 当Android选择使用哪个资源时,它对屏幕像素密度的处理和其它限定符不同。在文章后面描述的步骤1Android如何查找最匹配的目录中,屏幕密度总被认为是匹配的。在步骤4中,如果被考虑的限定符是屏幕密度,Android将选择在那个位置的最佳匹配,而无需继续步骤5。 |
触摸屏类型Touchscreentype | 非触摸式,触摸笔,手指(notouch,stylus, finger) |
键盘可用方式Whetherthe keyboard is available to the user | 外在键盘,隐藏键盘,软键盘(keysexposed,keyshidden,keyssoft) |
首选文本输入方法Primarytext input method | 不支持按键,标准键盘,12键(nokeys,qwerty, 12key) |
首选非触摸式导航方法Primarynon-touchscreen | 不支持导航,滑板,跟踪球,滚轮(nonav,dpad, trackball, wheel) |
屏幕分辨率Screendimensions | 320x240,640x480, 等. 更大的分辨率必须先被指定。 |
SDK版本SDKversion | 设备支持的SDK版本,比如v3。Android1.0SDK是v1,1.1SDK是v2,1.5SDK是v3。 |
小版本(Minorversion) | 你目前还不能指定小版本,它总是被设置为0。 |
文件夹命名的各个部分是有顺序的。即按上表从上到下的优先级别排列,如:
drawable-en-rUS-land-mdpi
drawable-en-rUS-port-160dpi-finger-qwerty-dpad-480x320/(US代表美式英语)
举个使用过程中的例子:
任意建一个android项目。看一下res目录结构:
drawable-hdpi-finger与drawable-ldpi目录下面两张图片名称一样,但是图片不是同一张,分别是:
、
layout、layout-finger、layout-land-finger下面的main.xml文件内容分别是:
layout/main.xml
[html] view plain copy
- <?xml version\="1.0" encoding\="utf-8"?>
-
<LinearLayout xmlns:android=“http://schemas.android.com/apk/res/android”
-
android:orientation=“vertical”
-
android:layout_width=“fill_parent”
-
android:layout_height=“fill_parent”
-
>
-
<ImageView
-
android:layout_width=“wrap_content”
-
android:layout_height=“wrap_content”
-
android:src=“@drawable/icon”
-
/>
-
<Button
-
android:layout_width=“wrap_content”
-
android:layout_height=“wrap_content”
-
android:background=“@drawable/icon”
-
/>
-
<TextView
-
android:layout_width=“fill_parent”
-
android:layout_height=“fill_parent”
-
android:text=“layout only”/>
-
</LinearLayout>
layout-finger/main.xml
[html] view plain copy
- <?xml version\="1.0" encoding\="utf-8"?>
-
<LinearLayout xmlns:android=“http://schemas.android.com/apk/res/android”
-
android:orientation=“vertical”
-
android:layout_width=“fill_parent”
-
android:layout_height=“fill_parent”
-
>
-
<ImageView
-
android:layout_width=“wrap_content”
-
android:layout_height=“wrap_content”
-
android:src=“@drawable/icon”
-
/>
-
<Button
-
android:layout_width=“wrap_content”
-
android:layout_height=“wrap_content”
-
android:background=“@drawable/icon”
-
/>
-
<TextView
-
android:layout_width=“fill_parent”
-
android:layout_height=“fill_parent”
-
android:text=“layout-finger”/>
-
</LinearLayout>
layout-land-finger/main.xml
[html] view plain copy
- <?xml version\="1.0" encoding\="utf-8"?>
-
<LinearLayout xmlns:android=“http://schemas.android.com/apk/res/android”
-
android:orientation=“vertical”
-
android:layout_width=“fill_parent”
-
android:layout_height=“fill_parent”
-
>
-
<ImageView
-
android:layout_width=“wrap_content”
-
android:layout_height=“wrap_content”
-
android:src=“@drawable/icon”
-
/>
-
<Button
-
android:layout_width=“wrap_content”
-
android:layout_height=“wrap_content”
-
android:background=“@drawable/icon”
-
/>
-
<TextView
-
android:layout_width=“fill_parent”
-
android:layout_height=“fill_parent”
-
android:text=“layout-land-finger”/>
-
</LinearLayout>
-
android:layout_width=“fill_parent”
-
android:layout_height=“fill_parent”
-
android:text=“layout-land-finger”/>
-
</LinearLayout>