Where is Android Studio layout preview?

2019-01-02 17:41发布

I installed Android Studio, but when I edit my layout files, I can't find live preview! I just see an XML file. How can I see my layout in graphical view?

Update: This is how it looks like in my case:

enter image description here

17条回答
浮光初槿花落
2楼-- · 2019-01-02 18:07

As etienne said be sure that the XML file you are looking at is in src/main/res/layout

I had the same issue. If you're in a layout file in build directory, you won't see a preview, nor will you have it as an option to enable. I wish Google had a slight warning for it.

查看更多
大哥的爱人
3楼-- · 2019-01-02 18:08

File>>setting>>Compiler>>JavaCompiler At "Project bytecode version(leave blank for jdk default):" choose your jdk.

enter image description here

查看更多
春风洒进眼中
4楼-- · 2019-01-02 18:11

I found 2 quick options to fix this:

  1. Just input in search "Preview" and it will show you a single result. Just click on it and preview appears again :)
  2. Pull the right-side line and window will appear. It's kinda resize.

Preview window in android studio

Happy coding!

查看更多
ら面具成の殇う
5楼-- · 2019-01-02 18:11

If you want to see the live preview, in the right part of the screen you should have a button call Preview that show/hide the live preview.

If what you want is to use the WYSISYG editor mode, in the bottom of the editor there is a tab that switch between XML mode and WYSISYG mode.

This works in the same way both in IntelliJ and Android Studio.

查看更多
弹指情弦暗扣
6楼-- · 2019-01-02 18:12

Navigate to file -> Project structure -> modules -> click on green plus button to add a module.

Select new module -> select Application Module in Android option -> give a module name -> next -> next -> finish

Select project that to be include in module -> click apply -> okay

Now you will be able to see the full project structure; then open the module form project window (the left panel), select res then select layout -> your layout name(.xml).

Now you will be able to see the design view and text view both...

查看更多
伤终究还是伤i
7楼-- · 2019-01-02 18:13

You should have a Design button next to the Text button under the xml text editor:

enter image description here

Or you can use the Preview button in the upper right corner to add a preview window next to the XML code:

enter image description here

UPDATE:

If you dont have it, then do this: View -> Tool Windows -> Preview

enter image description here

查看更多
登录 后发表回答