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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 21:46:48  来源:igfitidea点击:

Layout preview not working in Android Studio

eclipseandroid-layoutandroid-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).

永远不会消失的消息(见图)。

enter image description here
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

enter image description here
我已经在项目结构中正确设置了 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

尝试这个

  1. Build> Clean Project
  2. Build> Rebuild Project
  1. 构建>清理项目
  2. 构建>重建项目

It worked for me

它对我有用

回答by Elham Kohestani

Just do a right click on the layout preview and click on

只需右键单击布局预览,然后单击

Show Included in contentmain.xml

you can see it in the following image enter image description here

你可以在下图中看到它 enter image description here

回答by Fernando Martínez

I had the same problem and I solved as follow

我有同样的问题,我解决如下

  1. Update all build.gradle files with:
  1. 使用以下内容更新所有 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

  1. Closes de IDE and via Terminal/Console
  2. Do a clean: $gradle clean
  3. Do a build: $gradle build
  4. Assemble it: $gradle assembleDebug
  5. Open the Android Studio and be happy ;)
  1. 关闭 de IDE 并通过终端/控制台
  2. 做一个清洁: $gradle clean
  3. 做一个构建:$gradle build
  4. 组装它: $gradle assembleDebug
  5. 打开 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 :

我遇到了同样的问题 请按照以下步骤操作:

Done

完毕

回答by Lazar Ilic

In Android Studio

在 Android Studio 中

File>Invalidate Caches/Restart

文件>无效缓存/重启

that's how i fixed

我就是这样修复的

回答by Deepak Singh

You can try :

你可以试试 :

  1. Select Preview window(Focus on it)
  2. Unselect Floating mode and Pinned mode
  3. goto Window -> Active Tool Window ->
  4. Unselect Floating mode and Pinned mode
  5. Now you can see Docked window option here(Window -> Active Tool Window ->)
  6. Select Docked Window
  1. 选择预览窗口(专注于它)
  2. 取消选择浮动模式和固定模式
  3. 转到窗口 -> 活动工具窗口 ->
  4. 取消选择浮动模式和固定模式
  5. 现在您可以在此处看到停靠窗口选项(窗口 -> 活动工具窗口 ->)
  6. 选择停靠窗口