使用 Eclipse ADT 编辑 Android 布局
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9556215/
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
Editing Android Layout using Eclipse ADT
提问by kamikaze_pilot
Sorry for a noobish question,
抱歉问了一个菜鸟问题,
So I have eclipse, installed ADT, the sdk etc and everything is fine....I can click on an android layout xml and the ADT layout editor displays fine...so I closed eclipse
所以我有 eclipse,安装了 ADT,sdk 等,一切都很好......我可以点击一个 android 布局 xml,ADT 布局编辑器显示正常......所以我关闭了 eclipse
A couple weeks later, I open eclipse again, but then when I open an android layout xml, the layout editor does not display and it instead displays xml...how can I get android ADT's layout editor to display? Is there a specific perspective/configuration that I must access?
几周后,我再次打开 eclipse,但是当我打开一个 android 布局 xml 时,布局编辑器不显示,而是显示 xml...我怎样才能让 android ADT 的布局编辑器显示?是否有我必须访问的特定视角/配置?
采纳答案by hqt
There are two case:
有两种情况:
1) You open that file by Text Editor
. That default of Eclipse (and you have it before you install ADT). This is fast but not trivial to add/edit something in Android. With this case, nothing can done. (mean you can not use ADT layout editor to fix it) Just close the tab and do other thing (That I will say later)
1)您通过Text Editor
. Eclipse 的默认设置(在安装 ADT 之前您已经拥有它)。在 Android 中添加/编辑某些内容是快速但并非微不足道的。在这种情况下,什么也做不了。(意味着你不能使用 ADT 布局编辑器来修复它)只需关闭选项卡并做其他事情(我稍后会说)
2) You have changed to Text Mode
. With your question, I think you don't know that Android layout editor
has two mode: one for graphic and one for text (same with above). For this case, you should close this tab to have same case with above :D
2) 您已更改为Text Mode
. 对于你的问题,我想你不知道它Android layout editor
有两种模式:一种用于图形,一种用于文本(与上面相同)。对于这种情况,您应该关闭此选项卡以与上述情况相同:D
Fix:
使固定:
Choose your layout xml file. Right click choose open with
and choose Android layout editor
.
选择您的布局 xml 文件。右键单击选择open with
并选择Android layout editor
。
You will see :
你会看见 :
As you see in picture above (I color two tab), you just click to each tab and see magically. ( I think :P). (In your case, click to Graphical Layout
)
如上图所示(我为两个标签着色),您只需单击每个标签即可神奇地查看。(我认为:P)。(在您的情况下,请单击Graphical Layout
)
Notes: this trick will same with many others in Android
(Android Manifest file
... ) as you will see when choose open with
.
注意:这个技巧将与Android
( Android Manifest file
... ) 中的许多其他技巧相同,您将在选择时看到open with
。
Hope that will help you. Before that, I have met error like you. ;)
希望这会帮助你。在此之前,我也遇到过像你这样的错误。;)
回答by tobi.b
There should be a tab on the bottom of the xml window, where you can switch between layout and xml.
xml 窗口底部应该有一个选项卡,您可以在其中切换布局和 xml。
回答by E-Riz
- Make sure you've opened the .xml file in the Android Layout Editor. To be certain, right-click on the file and choose Open With from the pop-up menu.
- If it's already open in the Layout Editor, look at the bottom; there are two tabs, one for Design ("visual" mode) and another for Source. You might be looking at the Source tab.
- 确保您已在 Android 布局编辑器中打开 .xml 文件。可以肯定的是,右键单击文件并从弹出菜单中选择打开方式。
- 如果它已经在布局编辑器中打开,请查看底部;有两个选项卡,一个用于设计(“视觉”模式),另一个用于源。您可能正在查看“源”选项卡。