适应布局Android平台或API级别 [英] Adapt layout to Android platform or API level

查看:86
本文介绍了适应布局Android平台或API级别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关我目前正在开发的应用程序,我需要在不同的活动的布局适应用户的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的版本可以在设备上的东西,你想用<一个href="http://developer.android.com/intl/de/guide/practices/screens_support.html#qualifiers">configuration预选赛的。在具体的<一个href="http://developer.android.com/intl/de/guide/topics/resources/providing-resources.html#AlternativeResources">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 <​​/ code>的API级别。具体的API级别,可以发现在此页面

这篇关于适应布局Android平台或API级别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆