eclipse 布局预览在 Android Studio 中不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17365015/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Layout preview not working in Android Studio
提问by Thomas Kaliakos
I ported an android project from Eclipse to Android Studio. The project builds just fine. However I am not able to see any layout preview. When I go to the Design tab of a layout I get a
我将一个 android 项目从 Eclipse 移植到了 Android Studio。该项目构建得很好。但是我看不到任何布局预览。当我转到布局的“设计”选项卡时,我得到一个
Loading Configuration...
正在加载配置...
message that never goes away (see image).
永远不会消失的消息(见图)。
I have set correctly the Android SDK in the project structure.
This happens with all the xml files and I am not able to open the "Preview" window from
我已经在项目结构中正确设置了 Android SDK。所有 xml 文件都会发生这种情况,我无法从以下位置打开“预览”窗口
View -> Tool Windows -> Preview
查看 -> 工具窗口 -> 预览
I tried creating a new project and everything was showing fine. Am I missing something? Anyone faced a similar issue? Is there a chance that this is happening because the folder structure is not the default one? (The layouts are not under project/src/main/res/layoutbut under project/res/layout)
我尝试创建一个新项目,一切都显示正常。我错过了什么吗?有人遇到过类似的问题吗?是否有可能因为文件夹结构不是默认结构而发生这种情况?(布局不在project/src/main/res/layout下,而是在project/res/layout 下)
回答by kishan
Try this
尝试这个
- Build> Clean Project
- Build> Rebuild Project
- 构建>清理项目
- 构建>重建项目
It worked for me
它对我有用
回答by Elham Kohestani
回答by Fernando Martínez
I had the same problem and I solved as follow
我有同样的问题,我解决如下
- Update all build.gradle files with:
- 使用以下内容更新所有 build.gradle 文件:
classpath 'com.android.tools.build:gradle:0.5.+'
类路径 'com.android.tools.build:gradle:0.5.+'
Now android studio 0.2.+ uses gradle 0.5
现在 android studio 0.2.+ 使用 gradle 0.5
- Closes de IDE and via Terminal/Console
- Do a clean: $gradle clean
- Do a build: $gradle build
- Assemble it: $gradle assembleDebug
- Open the Android Studio and be happy ;)
- 关闭 de IDE 并通过终端/控制台
- 做一个清洁: $gradle clean
- 做一个构建:$gradle build
- 组装它: $gradle assembleDebug
- 打开 Android Studio 并感到高兴 ;)
回答by Badzalk
Close android studio and go to path as follow: C:\Users\user\ .AndroidStudio1.2\restart There is a file named restarter,double click on it and open android studio again,create a new project and enjoy it
关闭android studio,进入如下路径: C:\Users\user\.AndroidStudio1.2\restart 有一个名为restarter的文件,双击它再次打开android studio,新建一个项目,享受吧
回答by ENDEESA
Try updating your API to the latest version in the SDK manager ---- worked for me
尝试在 SDK 管理器中将您的 API 更新到最新版本 ---- 对我来说有效
回答by facundofarias
Maybe it is better to use the 0.3.6 version (latest), with this version of gradle : com.android.tools.build:gradle:0.6.+
也许最好使用 0.3.6 版本(最新),使用这个版本的 gradle :com.android.tools.build:gradle:0.6.+
Bear in mind that Android Studio will be expecting the Android SDK already installed (as I suppose you have), and also the environment variables ANDROID_HOME and GRADLE_HOME.
请记住,Android Studio 将期望已经安装了 Android SDK(我想您已经安装了),以及环境变量 ANDROID_HOME 和 GRADLE_HOME。
回答by Dhaval Jivani
I had the same problem Follow this step :
我遇到了同样的问题 请按照以下步骤操作:
- First uninstall old android studio and delete .androidstudio file from C:\Users\yourpcname
- update api to latest version in SDK manager.
- Install Latest Android Studio Canary Build: 2.0 Preview 9
- 首先卸载旧的 android studio 并从 C:\Users\yourpcname 中删除 .androidstudio 文件
- 在 SDK 管理器中将 api 更新到最新版本。
- 安装最新的 Android Studio Canary Build:2.0 Preview 9
Done
完毕
回答by Lazar Ilic
In Android Studio
在 Android Studio 中
File>Invalidate Caches/Restart
文件>无效缓存/重启
that's how i fixed
我就是这样修复的
回答by Deepak Singh
You can try :
你可以试试 :
- Select Preview window(Focus on it)
- Unselect Floating mode and Pinned mode
- goto Window -> Active Tool Window ->
- Unselect Floating mode and Pinned mode
- Now you can see Docked window option here(Window -> Active Tool Window ->)
- Select Docked Window
- 选择预览窗口(专注于它)
- 取消选择浮动模式和固定模式
- 转到窗口 -> 活动工具窗口 ->
- 取消选择浮动模式和固定模式
- 现在您可以在此处看到停靠窗口选项(窗口 -> 活动工具窗口 ->)
- 选择停靠窗口