适应布局Android平台或API级别布局、级别、平台、Android

由网友(花媚奴)分享简介:有关我目前正在开发的应用程序,我需要在不同的活动的布局适应用户的Andr​​oid API级。For the application I am currently developing, I need to adapt the layout of the different activities to the use...

有关我目前正在开发的应用程序,我需要在不同的活动的布局适应用户的Andr​​oid API级。

For the application I am currently developing, I need to adapt the layout of the different activities to the user's Android API level.

有没有办法做到这一点?

Is there a way to do this?

推荐答案

如果你正在试图做的是展现出不同的布局,这取决于API的版本可以在设备上的东西,你想用configuration预选赛的。在具体的alternative资源也记录在案。

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.

最基本的方法来做到这一点是创建布局文件夹,您要使用,格式化每个API级别,如下所示:

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)

等,其中 VN 的API级别。具体的API级别,可以发现在此页面。