在 Android Studio 布局设计预览中选择目标 API [英] Select target API in the Android Studio layout design preview

查看:30
本文介绍了在 Android Studio 布局设计预览中选择目标 API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序面向 API 17,但最小 Sdk 版本是 8.在布局设计预览页面中,我可以看到我的布局在 API 17 版本上的显示方式,但是如果我单击 API 选择器下拉菜单,我可以'不要选择任何其他 API 级别.显然我可以在 2.3 Android 版本中运行我的应用程序,在真实设备上我可以看到结果,但是有没有办法在设计预览页面中进行测试?

My application targets API 17 but the min Sdk version is the 8. In the layout design preview page I can se how my layout appears on an API 17 version, but if I click on the API selector drop down menu, I can't choose any other API level. Obviousely I can run my application in a 2.3 Android version and on a real device I can see the result, but is there a way to test in also in the design preview page?

我的清单片段:

    <uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" />

推荐答案

UPDATE

实际上我发现了问题所在:当您安装 Android Studio 时,默认情况下它使用自己的 Android SDK(位于 Android Studio.app/sdk 文件夹中),而不是您下载的(例如与 Eclipse 一起使用).

Actually I found out what the problem was: when you install Android Studio, by default it uses its own Android SDK (located in the Android Studio.app/sdk folder), instead of the ones you downloaded (for example to use with Eclipse).

所以我只是在我认为我正在使用的 SDK 和我实际使用的 SDK 之间存在偏差.要解决此问题,您有两种选择:

So I simply had a misalignement between the SDK I thought I was using and the ones I was actually using. To solve this you have 2 options:

-从 Android Studio 中选择文件 -> 项目结构.在平台设置"下,您可以添加(更新后的)下载的 SDK 文件夹并将其用于您的项目.

-from Android Studio select File -> Project Structure. Under "platform settings" you can add your (updated) downloaded SDK folder and use it for your projects.

-打开 Android Studio SDK 管理器并安装较旧的 android 版本 SDK

-open the Android Studio SDK manager and install also the older android versions SDKs

这篇关于在 Android Studio 布局设计预览中选择目标 API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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