首页 > 代码库 > Android - 资源xml文件适配不同的版本

Android - 资源xml文件适配不同的版本

资源xml文件适配不同的版本


本文地址:http://blog.csdn.net/caroline_wendy


Adapt layout to Android platform or API level:把布局文件适配不同的API级别,避免警告;
通过为不同的API等级,建立不同的文件夹(layout-v4),进行适配,可以去掉Warning.

具体:
If what you‘re trying to do is show a different layout depending on which API version is available on the device, you want to use configuration qualifiers. The specifics for alternative resources are also documented.

The most basic way to do it is to create a layout folder for each API level you want to use, formatted as follows:

res/layout/mylayout.xml       (Default)
res/layout-v4/mylayout.xml    (Android 1.6)
res/layout-v11/mylayout.xml   (Android 3.0)
and so on, where vN is the API level. The specific API levels can be found on this page.

参考:http://stackoverflow.com/questions/6536079/adapt-layout-to-android-platform-or-api-level

Android - 资源xml文件适配不同的版本