简体   繁体   English

打开XML文件时,我看不到图形布局

[英]I can't see the graphical layout when I open an XML file

It shows a blank screen. 它显示一个空白屏幕。 I then have to click the blue/gray star icon and choose App theme , only then will elements show in the palette. 然后我必须单击蓝色/灰色星形图标并选择App theme ,然后才会在调色板中显示元素。 I then have to drag an element from the palette onto the blank screen and drop it. 然后我必须将一个元素从调色板拖到空白屏幕上然后放下它。 Then the graphical layout will appear. 然后会出现图形布局。

It used to work fine until I started playing around with themes and ActionbarSherlock . 它曾经很好地工作,直到我开始玩主题和ActionbarSherlock

I tried restoring defaults on all Android and XML settings but it didnt work. 我尝试在所有Android和XML设置上恢复默认值,但它没有用。

Does anyone know how to fix it so that the XML graphical editor shows up when I open a layout XML file? 有没有人知道如何修复它,以便在打开布局XML文件时显示XML图形编辑器?

(The xml I am working with are not blank.) (我正在使用的xml不是空白。)

每天我都会遇到这个问题,特别是当我向工作区添加一个新的Andorid Project时,我找到的唯一解决方案是重启Eclipse ,我希望这对你也有帮助。

Try Like this : 试试这样:

Right clicking one of the layout files in the Package Explorer view 右键单击Package Explorer视图中的一个布局文件

Open With -> Android Layout Editor

I guess your issue is Eclipse related, but try to be specific next time about your IDE since it may help you get the right answer. 我想您的问题与Eclipse有关,但下次尝试具体说明您的IDE,因为它可以帮助您获得正确的答案。 If you're using Eclipse i recommend that you check that your Android SDK Tools Eclipse plug-in (ADT) is up to date. 如果您正在使用Eclipse,我建议您检查您的Android SDK Tools Eclipse插件(ADT)是否是最新的。

This happens with me sometimes if I haven't chosen an android version in the top-right corner of the graphical layout editor. 如果我没有在图形布局编辑器的右上角选择Android版本,有时会发生这种情况。 Because the same theme might look different in different versions of Android, I guess eclipse doesn't know what to show you unless you select a specific version of android for the theme you have chosen. 因为在不同版本的Android中相同的主题可能看起来不同,我想eclipse不知道该向你展示什么,除非你为你选择的主题选择了特定版本的android。

It also sometimes happens with me, If I have used a Google API's version instead of Android XX version as target build for my project. 它有时也发生在我身上,如果我使用Google API的版本而不是Android XX版本作为我的项目的目标版本。 Maybe some bug in the developer tools. 也许是开发人员工具中的一些错误。

Try to increase -Xms128m -Xmx1024m when launch eclipse. 启动eclipse时尝试增加-Xms128m -Xmx1024m。 I had the same problem because i don't have enough memory. 我有同样的问题,因为我没有足够的内存。

Hope this helps. 希望这可以帮助。

Ok, so my best understanding is that you somehow overwrote or changed the default theme for that project with something other than AppTheme. 好的,所以我最好的理解是你以某种方式覆盖或改变了该项目的默认主题,而不是AppTheme。 You should be able to change that in the styles xml file (ProjectPath/res/values/styles.xml), assuming this is the same project. 您应该能够在样式xml文件(ProjectPath / res / values / styles.xml)中更改它,假设这是同一个项目。

For reference, mine works fine, and my project's styles.xml looks like this (new project): 作为参考,我的工作正常,我的项目的styles.xml看起来像这样(新项目):

<resources>

    <style name="AppTheme" parent="android:Theme.Light" />

</resources>

In the eclipse, right click on your XML file and choose Open With and then XML Editor 在eclipse中,右键单击XML文件并选择Open With ,然后选择XML Editor

At the bottom of the page, you'll see Design and Source tabs. 在页面底部,您将看到“ 设计”和“ 源”选项卡。 Click on the Source to see what you desired. 单击“源”以查看所需内容。

mine never refreshes. 我永远不会刷新。 So i open up another file then return back and then it refreshes. 所以我打开另一个文件然后返回然后刷新。 Even if i go to the palette to refresh it was not working. 即使我去调色板刷新它也无法正常工作。 Also like others mentioned make sure your your api version is application to what you want rendered. 与其他提到的一样,请确保您的api版本适用于您想要呈现的内容。 So mine was set to api 20 but my project runs on api 17 so play with it. 所以我的设置为api 20但是我的项目在api 17运行,所以玩它。 Heres a image: 下图:

在此输入图像描述

notice how mines set to 17 - yours might be at 20 or something else that differs from your manifest. 注意如何设置为17 - 你的地雷可能是20或其他与你的清单不同的地方。 change it accordingly. 相应地改变它。

Solution for andoird Studio Users. andoird Studio用户的解决方案。 Below solution worked for me. 以下解决方案适合我。

File --> Invalidate Caches and Restart --> Invalidate and Restart. 文件 - >使高速缓存无效并重新启动 - >无效并重新启动。

Hope this will work for you too. 希望这也适合你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我在NetBeans中看不到图形布局android - I can't see the graphical layout android in NetBeans 如何在Eclipse中打开新xml文件的图形布局选项卡? - How can I open the graphical layout tab for a new xml file in eclipse? 看不到Android的图形布局 - Can't see Android graphical layout 在日食中看不到图形布局 - Can't See Graphical Layout in eclipse 在Eclipse中以图形布局打开xml文件时遇到了麻烦 - I got some trouble when i opened the xml file in Eclipse ( in Graphical Layout ) 打开任何android应用程序时如何显示布局(xml文件)? - how i can show my layout(xml file) when i open any android app? 我无法拖放任何东西来布局Android中的图形界面 - I can't drag or drop anything to layout graphical interface in Android 如何在activity_main.xml的图形布局中获取电话屏幕布局? 我只能看到标签版式 - How to get phone screen layouts in graphical layout of activity_main.xml ? I see only tab layouts Android Eclipse&gt;图形布局:如何为我打开的每个XML布局设置默认布局= Nexus 7或不是2,以便在IDE和设备中看起来相同 - Android Eclipse > Graphical Layout: How to Set Default Layout = Nexus 7 or Not 2 for every XML layout I open to look same in IDE and Device 我是否应该能够在Eclipse Graphical Layout中看到android滚动条? - Am I supposed to be able to see the android scrollbar in the Eclipse Graphical Layout?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM