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 17:53

Got the same problem after importing my Eclipse ADT project to Android Studio. Text and Desing tabs where missing.

Found my Event Log windows reads "Frameworks detected: Android framework is detected in the project Configure"

I click the hyperlink provided and everything was fixed, Text and Desing tabs became visible and functional

查看更多
初与友歌
3楼-- · 2019-01-02 17:54

I had this problem a couple hours ago when I exported my projects from Eclipse to Android Studio. Unfortunately, the top answers here didn't work for me.

Anyway, creating a new project instead of opening an old one did the trick for me as what Thomas Kaliakos mentioned on his comment here

I had to mess around with the project..and at some point it worked. I don't know how though. My guess would be that creating a new project and adding your source code would work every time. Sorry for not being very clear, but honestly I was surprized even myself that it worked. – Thomas Kaliakos Oct 15 '13 at 4:08

查看更多
刘海飞了
4楼-- · 2019-01-02 17:55

first of all after creating the new app

go to java->MainActivity

and open a new tab for it

In the java code click on the index numberings where you can see the code logoenter image description here

as red circled in picture

left click on it and you will see two options as shown in below pictureenter image description here

click on the first option so that you can preview your app in android studio

查看更多
余生无你
5楼-- · 2019-01-02 17:56
  1. Select MainActivity.java file from the left pane, as shown in the red colored rectangle.

  2. Left click the XML Tag icon as shown in the red colored circle.

  3. Select the "activity_main.xml(layout)" option shown highlighted in the below figure.

enter image description here

查看更多
浅入江南
6楼-- · 2019-01-02 17:59

In case that helps anyone, I had the same issue today where the 'design / text' tabs were missing. I had switched to the dark theme and thought maybe that was the issue, so went back to Preferences / Appearance (under IDE settings) switched back to Default Theme, and that reset everything correctly for me. I could also then switch again to Darcula theme and the tabs were still there, so seems like switching themes is a way to reset the IDE windows/tabs.

查看更多
柔情千种
7楼-- · 2019-01-02 18:06

Several people seem to have the same problem. The issue is that the IDE only displays the preview if editing a layout file in the res/layout* directory of an Android project.

In particular, it won't show if editing a file in build/res/layout* since those are not source directory but output directory. In your case, you are editing a file in the build/ directory...

The Resource folder is set automatically, and can be viewed (and changed) in Project Structure > Modules > [Module name] > Android > Resources directory.

查看更多
登录 后发表回答