185

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

This is how it looks like in my case:

enter image description here

Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
Fcoder
  • 9,066
  • 17
  • 63
  • 100

25 Answers25

359

UPDATE 2 (2020-03-16)

The newer Android Studio version changed the location of this button. Now if you want to see the layout design preview you will need to press one of the buttons at the top right of your xml. The button that looks like an image icon will open the design dashboard, while the button next to it will open the split view where the design is placed next to the XML code:

enter image description here

ORIGINAL (2013-05-21)

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

Emil Adz
  • 40,709
  • 36
  • 140
  • 187
  • 45
    i dont have this options at all!! – Fcoder May 21 '13 at 00:07
  • You can see in the answer a full screen shot of my IDE and you see that those options exist. You probably have done something with yours to remove those options. Try to redownload Android Studio. – Emil Adz May 21 '13 at 00:09
  • 3
    i updated my question, i put my screenshot. i download it recently and dont change anything! – Fcoder May 21 '13 at 00:11
  • 1
    As solange points out below, you might not be able to see these two bottom tabs, "Design" and "Text", if you're using the darker Dracula theme. Switch back to the Default theme and see if they are there. – Joshua Pinter Sep 19 '13 at 01:40
  • 6
    I have this option but disabled ! – Pejman Oct 29 '13 at 06:58
  • 2
    Thank you! My preview disappeared and I could not figure where on earth it went to (I think one of my children must have hit something). THANK YOU! – tm_forthefuture Jun 23 '14 at 08:56
  • 5
    For everyone that cant see the preview on view> windows tool you MUST be in "text" tab on the xml editor to see the option – D4rWiNS Aug 04 '15 at 09:20
  • This has happened numerous times and I've come back to this answer every time and see that I've already upvoted it. – MaxJ Sep 18 '15 at 08:32
  • when i use coordinatelayout the layout preview is not available in android studio.for other basic view preview is available please help me. – Harsha Oct 27 '15 at 09:08
  • 1
    I had this problem. View->Tool Windows->Preview was greyed out, even though I have the layout file open. Switching to design tab and then back to text suddenly enables the previously disabled preview window. WTF? – Robert Tuck Oct 03 '17 at 10:35
  • @RobertTuck, Didn't see this problem, sounds like a bug in Android Studio. – Emil Adz Oct 03 '17 at 10:38
  • 1
    The `Preview` option on `View` > `Tool Windows` has been removed between version 3.5 and 3.6 of Android Studio. Instead, use the `Design` tab on your resource to see the preview. – Gustaf Liljegren Oct 26 '19 at 14:59
  • @GustafLiljegren still have it in the latest stable version (3.5.1) – Emil Adz Oct 27 '19 at 19:30
  • Could this question be streamlined to not include so many upgrades? For people who find this answer now it's not really especially interesting to dig through all the updates to find what they need. Ideally we'd have the current version at the top with older versions still mentioned below for those who use older versions of Android Studio. – Joachim Sauer Sep 15 '21 at 12:32
56

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.

etienne
  • 3,146
  • 1
  • 24
  • 45
19
  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

MNS
  • 1,354
  • 15
  • 26
17

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.

solange
  • 335
  • 3
  • 7
  • Boom! Thank you. I had the same issue where I was using the Dracula theme and had to switch back to the Default theme in order to see the "Design" and "Text" tabs visible at the bottom. Cheers. – Joshua Pinter Sep 19 '13 at 01:39
  • I was missing the tabs on the bottom, this worked for me with the latest release as of 9/25/13. However, it didnt switch my theme back, just the code editor window.. still fairly buggy.. great promise though – hanzolo Sep 25 '13 at 18:50
12

The following worked for me:

-> file

-> settings

-> plugins

-> disable the android support plugin

-> you will be prompted to restart

-> once restarted re-enable the plugin and other dependency plugins that might have been disabled in the process

-> you will be prompted to restart once again. Hopefully when android studio restarts the second time the preview should render.

sirFunkenstine
  • 8,135
  • 6
  • 40
  • 57
10

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!

Yurets
  • 3,999
  • 17
  • 54
  • 74
8

For those struggling in Android Studio 3.6:

enter image description here

Fernando Carvalhosa
  • 1,098
  • 1
  • 15
  • 23
7

Go to File->Invalidate Caches / Restart.

This will solve the issue.

Vilas
  • 1,695
  • 1
  • 13
  • 13
5

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

Víctor Silva
  • 51
  • 1
  • 1
4

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...

Christopher Orr
  • 110,418
  • 27
  • 198
  • 193
Vishal Pandey
  • 696
  • 8
  • 7
2

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.

CRABOLO
  • 8,605
  • 39
  • 41
  • 68
Merlin -they-them-
  • 2,731
  • 3
  • 22
  • 39
2

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

1

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.

jpintado
  • 365
  • 1
  • 7
0

I had the same issue and resolved by editing the t file in src>main>res>layout. You can choose between Test and Design mode at the bottom of editor.

Quite simple if we know where to look for !!! spend few hours figuring it out!!!

SKV
  • 9
  • 3
0

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

Community
  • 1
  • 1
rsano
  • 1,230
  • 1
  • 12
  • 19
0

In case you want docked mode, (it still visible while editing the xml file), and you, by mistake, clicked and unmarked docked mode. In order to get it back you have focus on preview and click Window > Active Tool Window > Docked Mode.

Ratata Tata
  • 2,781
  • 1
  • 34
  • 49
0

If you see a message at the bottom saying something like, "Android Framework detected. Click to configure", DO IT.

After doing this, my Text and Design bottom-tabs appeared.

cdabel
  • 461
  • 9
  • 21
0

In my case, I don't have Design or Preview tab.

Try

  • Configure the proxy rightly to download necessary components
  • Configure the android-sdk path to contains no space character
  • Restart Android Studio in Admin mode
Rika
  • 21
  • 2
  • 3
0
  1. Go to File->Invalidate Caches/ Restart. After restarting the preview window will come.

  2. Still the preview window is not opened, Go to View -> Tool window -> click Preview

0

Go to File > Settings > Appearance & Behavior > Appearance > Show tool window bars

Sumit Garai
  • 1,205
  • 8
  • 6
0

I am using Android studio 3.3 and this method worked for me: open settings from file/settings from the left panel select Editor then layout Editor then from the right panel uncheck third option which is "Hide preview window when editing non-layout files" then hit apply then ok. then go to view/tool windows/preview is enable now in the design tab of layout XD. Do not forget up vote and marking this answer as the right answer. Happy coding. enter image description here

Reflection
  • 399
  • 2
  • 11
0

Just need search the appropiate folder that contains your app layour, in this case you can find in your repository folders: AppName>res>layout and double click in the layout of your preference activity main normally contains the principal things of your view enter image description here

IMPORTANT: Check that you have activated the design visualization at the top-right corner (Image icon)

Heterocigoto
  • 183
  • 2
  • 11
0

I have Android studio version "Arctic Fox | 2020.3.1".

Step 1- Open you xml file.

enter image description here

Step 2- From top right below Gradle you will get Layout Validation option click on it.

enter image description here

Step 3 - Click on "view option" (eye icon) in Layout Validation panel. You will see on drop down with "Show System UI" option. Select this after that you can see preview of your design.

enter image description here

Dipak
  • 2,263
  • 1
  • 21
  • 27
0

The solution is releted to the latest Android Studio Dolphin Version

After alot of searching and testing, I upgraded my gradle version and its work for me.

Just goto File -> Project Structure or press Ctrl + Alt + Shift + S and then upgrate the gradle version as shown in the image below and then invalidate cache and restart the Android Studio and its working

enter image description here

As shown in the image I upgrade my gradle

Happy Coding With Android Studio :)

Syed Rafaqat Hussain
  • 1,009
  • 1
  • 9
  • 33
-1

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

enter image description here

blahdiblah
  • 33,069
  • 21
  • 98
  • 152
KZM
  • 1